g++-3.4 bug

Marc Glisse marc.glisse at inria.fr
Thu Feb 16 22:24:11 CET 2012


Hello,

some tests currently fail on gmpxx with g++-3.4 (on shell). This is due to 
a bug in g++-3.4, which for l=2 says the following is true:
__builtin_constant_p(l) && (l == 0)
it is interesting to insert a printf statement that prints both l and l==0 
and have it print 2 and true :-/

More recent versions like g++42 seem fine. There are various simple 
workarounds that make g++34 happy (although in principle they shouldn't 
change anything), but that seems a bit dangerous (who knows where the bug 
might be lurking?). My current plan is to replace the test for the 
existence of __builtin_constant_p from __GNUC__ >= 2 to 
__GMP_GNUC_PREREQ(4, 2) (or possibly 4.0 or 4.1 if I can get access to 
either to check if the bug is present). This would only affect the use of 
__builtin_constant_p in gmpxx.h (not anywhere else, in particular not 
gmp.h), which is new in gmp-5.1.

Does that sound ok?

-- 
Marc Glisse


More information about the gmp-devel mailing list