Bug in gcc 2.95.2 optimizer for SPARC

Per Espen Hagen peh@ffi.no
Wed Jun 28 02:02:00 GMT 2000


Hello,

While developing a program for controlling autonomous underwater
vehicles, we have discovered a bug in GCC 2.95.2.  Specifically, the
optimizer (-O2) for SPARC generates incorrect code.


Host computer:
Sun Ultra 1 (also found on Ultra 2 and SS-10) running Solaris 7 MU 4.

% uname -a
SunOS hugin2 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-1

Compiler:
GCC 2.95.2, as downloaded from http://www.sunfreeware.com/
(pre-compiled)

% gcc -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)


We have managed to reproduce the bug in a simple program.  Attached
please find a tar archive with the following files:

bug.c  - The program (378 bytes)
bug    - Executable (command line: "gcc -g -O2 -o bug bug.c")
output - Compilation command line and program output

Some of the code (such as the "case 2" in the switch) may seem like
noise, but it is necessary to trigger the bug.  The bug manifests itself
between line 19 and 28.  A member of a union (v.i) is divided by 1000
within the switch, but the new value is not preserved after the switch. 
In effect, the union member is treated as a local variable in the
switch.

The bug does not appear under the other platforms we use (Solaris x86,
Linux x86), nor does it appear when compiling with -O1 or without
optimization.

If you need any additional information, please mail me.

-- 
Per Espen Hagen, Principal Scientist
Norwegian Defence Research Establishment
bug.tar

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.tar
Type: application/x-tar
Size: 13312 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000628/fc87cfb4/attachment.tar>


More information about the Gcc-bugs mailing list