gcc 2.95.1 bug

Paul F. Kunz pfkeb@slac.stanford.edu
Sun Oct 31 23:03:00 GMT 1999


> Short description:

> I have two small files, bug.c and bug2.c, and a shared header bug.h.
> When bug2.c is compiled with -O and bug.c is compiled with no flags,
> the program demonstrates non-deterministic behaviour and starts
> spitting out NaN values.

> Longer description:

> bug.c contains a subroutine bug() that does two things.  First, it
> calls a routine called matrix3x3_invert in bug2.c to return the
> inverse of an input matrix (the identity matrix), where both input
> and return value are structs containing the elements of the matrix.
> bug() checks for NaNs in the returned matrix.  Second, it calls a
> function foo() that returns a different struct with one element.

> The main program just calls bug() repeatedly many times.  When
> bug2.c is compiled with -O and bug.c is compiled with no flags,
> bug() detects a NaN after it is called 4 times.

> gcc 2.8.1 and 2.7.2.3 don't seem to demonstrate the error.

   I can give so more information on this problem.   If one sets a
break point at the entrance of the matrix3x3_inverse() function, one
will see that the first time it is entered all the floating point
registers are marked empty (use the `info float' gdb command).   The
second time it is entered, one FP register is marked `valid' and the
third time two are marked `valid'.   By the time you enter the fourth
time, three are marked `valid' and after you return the code overflows
the FP stack.   Then the stack overflows, a `-NaN' is entered into the
stack, instead of what you asked for.

   I have exactly the same problem in a different and much more
complex context.   For me, a member function of a C++ class overflows
the FP stack on the first call to it.

   I'm way over my head in understanding this problem, but it appears
that something is leaving stuff on the stack and eventually it
overflows.   This makes gcc 2.95.1 about useless for scientific
calculations.   I hope someone can find a fix soon.



More information about the Gcc-bugs mailing list