optimization/2847: GCC 2.96 with -O2 incorrectly compile if(var==0)break; else printf("test\n"); inside a while
Gwenole Beauchesne
gbeauchesne@mandrakesoft.com
Tue Aug 14 07:19:00 GMT 2001
Hi,
> Synopsis: GCC 2.96 with -O2 incorrectly compile if(var==0) break; else printf("test\n"); inside a while
>
> State-Changed-From-To: open->closed
> State-Changed-By: rodrigc
> State-Changed-When: Mon Aug 13 16:03:16 2001
> State-Changed-Why:
> Works with: gcc version 3.0.1 20010813
>
> Please contact Mandrake with issues regarding the
> compiler supplied with Mandrake Linux.
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2847&database=gcc
I am sorry but it doesn't seem to work either with gcc version 3.0.1
20010814. I believe the correct result should be:
[gbeauchesne@thalys vrac]$ ./a.out
iNbr = 1
Wonderful
(don't miss the first printf() when entering the loop)
Funny enough, the behavior between "2.96" and 3.0.1 differs a bit:
[gbeauchesne@thalys vrac]$ gcc-2.96 -v
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/2.96/specs
gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.61mdk)
[gbeauchesne@thalys vrac]$ gcc-2.96 -O2 ./while.c && ./a.out
iNbr = 1
[gbeauchesne@thalys vrac]$ gcc-3.0.1 -v
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.0.1/specs
gcc version 3.0.1 20010814 (Mandrake Linux 8.1 3.0.1-0.3mdk)
[gbeauchesne@thalys vrac]$ gcc-3.0.1 -O2 ./while.c && ./a.out
Wonderful
And finally,
[gbeauchesne@thalys vrac]$ gcc-3.0.1 -O2 -fno-strength-reduce ./while.c &&
./a.out
iNbr = 1
Wonderful
Please find enclosed a slightly modified version of the test program. Here
are the results for gcc-3.0.1:
[gbeauchesne@thalys vrac]$ CC="gcc-3.0.1" sh ./wonderful.c
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.0.1/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --enable-long-long --enable-cstdio=stdio
--enable-clocale=generic --enable-languages=c,c++,f77,objc,java
--program-suffix=-3.0.1 --enable-objc-gc --host=i586-mandrake-linux-gnu
Thread model: posix
gcc version 3.0.1 20010814 (Mandrake Linux 8.1 3.0.1-0.3mdk)
CC: gcc-3.0.1; CFLAGS: -O1
>> PASS
CC: gcc-3.0.1; CFLAGS: -O1 -fstrength-reduce
>> FAIL
CC: gcc-3.0.1; CFLAGS: -O2
>> FAIL
CC: gcc-3.0.1; CFLAGS: -O2 -fno-strength-reduce
>> PASS
IMHO, this is a regression from 2.95.X.
You may want to check the following page for other results:
< https://qa.mandrakesoft.com/cgi-bin/show_bug.cgi?id=4221 >
Bye,
Gwenole.
More information about the Gcc-bugs
mailing list