This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Implement floordiv operator for gdb.Value


On 20/09/16 17:35 +0100, Jonathan Wakely wrote:
On 20/09/16 16:33 +0100, Pedro Alves wrote:
@@ -1142,7 +1160,15 @@ valpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other)
    }

  if (res_val)
-    result = value_to_value_object (res_val);
+    {
+      if (floor_it)
+        {
+          double d = value_as_double (res_val);

Should be s/double/DOUBLEST, I suppose?

OK - if I do that then floor(d) will convert it back to double,
unless you #include <cmath> and using std::floor, so that the overload
for long double is visible (in C++ <math.h> names like floor are
overloaded so you don't need to use floorf/floor/floorl according to
the type).

P.S. In theory it should work with <math.h> and without the
using-declaration, but with GCC that wasn't true until GCC 6.1 (see
http://developerblog.redhat.com/2016/02/29/why-cstdlib-is-more-complicated-than-you-might-think/
for the gory details).

So to get the right result for older versions of GCC you need <cmath>.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]