This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

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


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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-02-19 10:16:17 UTC ---
Yeah, the bug is obvious.  glibc refuses to compile with -O0, so it was never a
problem for it.
The problem is that while mpn_lshift_1 function is always_inline, at -O0 the
__builtin_constant_p folds to 0 early in:
if (__builtin_constant_p (count) && count == BITS_PER_MP_LIMB)
and the else code isn't prepared to handle BITS_PER_MP_LIMB value.
The function is always either called with constant BITS_PER_MP_LIMB count, or
variable count that is always < BITS_PER_MP_LIMB, so it works fine for -O1+.

To fix this, either mpn_lshift_1 could be rewritten as macro, or as a macro
calling two different inline functions, or __builtin_constant_p (count) &&
could be guarded with #ifdef __OPTIMIZE__.


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