summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2018-05-19 13:13:02 -0500
committerDamien George <damien.p.george@gmail.com>2018-05-21 12:49:56 +1000
commit95e43efc994af7d7ff85ef1722eac163be9cc5fd (patch)
tree5bfda0eef366d02e14e141ca5a75f82612ba352c
parentc4dafcef4fe9edaacaeeb16c412c298cbab3b414 (diff)
py/objfloat: Fix undefined integer behavior hashing negative zero.
Under ubsan, when evaluating hash(-0.) the following diagnostic occurs: ../../py/objfloat.c:102:15: runtime error: negation of -9223372036854775808 cannot be represented in type 'mp_int_t' (aka 'long'); cast to an unsigned type to negate this value to itself So do just that, to tell the compiler that we want to perform this operation using modulo arithmetic rules.
-rw-r--r--py/objfloat.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objfloat.c b/py/objfloat.c
index 31c624778..b62fe8e71 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -99,7 +99,7 @@ typedef uint32_t mp_float_uint_t;
}
if (u.p.sgn) {
- val = -val;
+ val = -(mp_uint_t)val;
}
return val;