avoid undefined behavior in hashing inexacts
Casting a negative floating-point number to an unsigned integer is not ok. Corece to a signed integer, first. Thanks to John Regehr for help.
This commit is contained in:
parent
b7bcd4f687
commit
0b9cda5018
|
@ -1117,7 +1117,7 @@ XFORM_NONGCING static uintptr_t dbl_hash_val(double d)
|
|||
d = frexp(d, &e);
|
||||
}
|
||||
|
||||
return ((uintptr_t)(d * (1 << 30))) + e;
|
||||
return ((uintptr_t)(intptr_t)(d * (1 << 30))) + (uintptr_t)e;
|
||||
}
|
||||
|
||||
XFORM_NONGCING static uintptr_t dbl_hash2_val(double d)
|
||||
|
|
Loading…
Reference in New Issue
Block a user