g++-3.4 bug
Marc Glisse
marc.glisse at inria.fr
Mon Feb 20 20:39:43 CET 2012
On Mon, 20 Feb 2012, Richard Guenther wrote:
> On Thu, 16 Feb 2012, Marc Glisse wrote:
>
>> 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 :-/
>
> Not for me.
>
> int main () { int l = 2; if (__builtin_constant_p (l) && (l == 0)) return
> 1; return 0; }
Did you try getting a snapshot of the gmp repos and running the c++
testsuite? Yes, your simple example passes, but you know better than I do
how much the context matters for optimizations. And since the bug doesn't
seem reproducible with more recent versions of gcc, there is little
motivation to reduce the failing tests.
The failing compiler was 3.4.6, from ports on freebsd 8.1, with -O2 -m64.
4.2.5 seems good.
In gmpxx.h, you can do this change:
struct __gmp_binary_lshift // LINE 425
{
static void eval(mpz_ptr z, mpz_srcptr w, mp_bitcnt_t l)
{
if (__GMPXX_CONSTANT(l) && (l == 0))
{
std::cerr << l << '\n'; // NEW LINE
if (z != w) mpz_set(z, w);
}
(and replace <iosfwd> with <iostream> at the beginning)
and wonder why it prints "2"...
--
Marc Glisse
More information about the gmp-devel
mailing list