GCC 4.3.2 bug (was: Illegal subtraction in tmp-dive_1.s)

Torbjorn Granlund tg at gmplib.org
Fri Apr 17 13:52:39 CEST 2009


Vincent Lefevre <vincent at vinc17.org> writes:

  On 2009-04-17 10:29:36 +0200, Torbjorn Granlund wrote:
  > Good.  (And I am glad you didn't use GCC 4.3.2 which miscompiles
  > mpn/generic/rootrem.c, incidentally!)
  
  Do you have any reference, e.g. on GCC's Bugzilla, and a simple
  testcase?
  
Unfortunately, I don't.

I discovered this bug quite late, when GCC 4.3.3 was already out, and since
the bug does not happen there, I decided not to isolate it.

(The bug might still be present, just masked by other compiler changes,
so ideally one should isolate every bug.  But I simply don't have time
to isolate all compiler bugs I run into.)

The smallest test case I have is to build gmp using the compiler and run
make check.  :-)

There is a special fixed test case in gmp-4.3.0/test/mpz/t-root.c that
triggers this bug.  It triggers on a 64-bit machines.  I know for sure
that 4.3.2 miscompiles the file 32-bit machines too, but I am not sure
t-root.c triggers that.

If the test does not trigger 32-bit problems, one should be able to
generate a new test case by using a loop like this:

  while true; do GMP_CHECK_RANDOMIZE=1 t-root || break; done

Unfortunately, this is likely to generate very large operands.  Editing
the test case code, replacing the "% 12" with something like "% 8"
should help generate a smallish test case.

It is actually quite important to find a failing test case, as a normal
"make check" apparently does not trigger the bug.

  This is particularly annoying since GCC 4.3.2 is the main GCC version
  under Debian/stable (lenny), and I've checked that the bug is present
  under Debian. I've reported the bug in the Debian BTS, hoping that
  there would be a backport of the patch.

OK.

I actually tried quite hard to find a non-contorted variant of the
problematic file (mpn/generic/rootrem.c) that gcc would not miscompile,
but I failed.

-- 
Torbjörn


More information about the gmp-discuss mailing list