This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Posible bug in gcc: Optimization bug - 2.95.2
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Posible bug in gcc: Optimization bug - 2.95.2
- From: Shawn Starr <spstarr at sh0n dot net>
- Date: Tue, 13 Mar 2001 19:20:52 -0500
NOTE: Someone on the linux-kernel mailing list mentioned this. I have also
tested and confirmed this as a bug on my system so I'm forwarding this to the
GCC bug team.
My GCC Information:
gcc -v
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
[spstarr@coredump spstarr]$ gcc bug.c -o a
--- OK ----
./a
[spstarr@coredump spstarr]$ ./a
Correct output: 5 2
GCC output: 5 2
---- FAULT ----
gcc bug.c -O2 -o a
[spstarr@coredump spstarr]$ ./a
Correct output: 5 2
GCC output: 10 5 <--- FAULT
---- OK ----
gcc bug.c -fno-strength-reduce -O2 -o a -save-temps
[spstarr@coredump spstarr]$ ./a
Correct output: 5 2
GCC output: 5 2
Included in tar are the files:
[spstarr@coredump spstarr]$ ls -la bug*
-rw-r--r-- 1 spstarr users 999 Mar 13 19:07 bug.c
-rw-r--r-- 1 spstarr users 867 Mar 13 19:16 bug.i
-rw-r--r-- 1 spstarr users 867 Mar 13 19:11
bug.i.with-no-strength-reduce
-rw-r--r-- 1 spstarr users 867 Mar 13 19:13
bug.i.without-no-strength-reduce
-rw-r--r-- 1 spstarr users 1.2k Mar 13 19:13 bug.o
-rw-r--r-- 1 spstarr users 1.7k Mar 13 19:17 bug.s.fail
-rw-r--r-- 1 spstarr users 1.7k Mar 13 19:17 bug.s.ok
I hope this helps :)
Shawn.
David wrote:
> I hope you will find this information usefull.
>
> I am not in the linux-kernel list so, if posible, I would like to be
> personally CC'ed the answers/comments sent to the list in response to
> this posting.
>
> I think I heve found a bug in gcc. I have tried both egcs 1.1.2 (gcc
> 2.91.66) and gcc 2.95.2 versions.
>
> I am attaching you a simplified test program ('bug.c', a really simple
> program).
>
> To generate the faulty program from correct code compile as:
> gcc -O2 -o bug bug.c
>
> You can generate good code in two ways:
> 1. Compiling with:
> gcc -fno-strength-reduce -O2 -o bug bug.c
>
> So the problem is with the option -fstrength-reduce which is
> active with the common '-O2' optimization option.
>
> 2. Uncomment the printf at line 34. Bugs are surprising.
>
> Is it really a bug?
>
> Thank you,
>
> David Llorens.
>
optbug.tar.gz