[Bug libquadmath/56379] libquadmath: Wrong result for strtoflt128.c if compiled with -O0

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 18 23:42:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56379

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-02-18 23:42:18 UTC ---
Some debugging. If one adds the following debugging patch:

--- a/libquadmath/strtod/strtod_l.c
+++ b/libquadmath/strtod/strtod_l.c
@@ -441,3 +441,5 @@ mpn_lshift_1 (mp_limb_t *ptr, mp_size_t size, unsigned int
count,
     {
+printf("1:mpn_lshift_1 ptr=%lu, size=%u, count=%u\n", ptr[0], size, count);
       (void) mpn_lshift (ptr, ptr, size, count);
+printf("2:mpn_lshift_1 ptr=%lu, size=%u, count=%u\n", ptr[0], size, count);
       ptr[0] |= limb >> (BITS_PER_MP_LIMB - count);


One gets with -O1 (for strtod/strtoflt128.c):
1:mpn_lshift_1 ptr=7640891576956012808, size=2, count=48
2:mpn_lshift_1 ptr=14485828201437200384, size=2, count=48
sqrt(2)=1.41421356237309504880168872420969798
r      =1.41421356237309504880168872420969798


And with -O0 (for strtod/strtoflt128.c):
1:mpn_lshift_1 ptr=1, size=2, count=64
2:mpn_lshift_1 ptr=1, size=2, count=64
1:mpn_lshift_1 ptr=7640891576956012809, size=2, count=48
2:mpn_lshift_1 ptr=14486109676413911040, size=2, count=48
sqrt(2)=1.41421356237309504880168872420969798
r      =1.41421356237309504885589883283397321


Note: "mpn_lshift" itself is in printf/lshift.c, which is compiled with default
options, i.e. with -O2.



More information about the Gcc-bugs mailing list