c/2635: Incorrect output in SIMPLE program when using -O2 (Both Linux and Solaris) gcc version 2.95.2 19991024 (release)gcc version 2.95.2 19991024 (release)
Wed Apr 25 05:06:00 GMT 2001
>Synopsis: Incorrect output in SIMPLE program when using -O2 (Both Linux and Solaris) gcc version 2.95.2 19991024 (release)gcc version 2.95.2 19991024 (release)
>Arrival-Date: Wed Apr 25 05:06:01 PDT 2001
>Originator: Charles Ross (email@example.com)
>Release: gcc version 2.95.2 19991024 (release)
Redhat Linux 6.2 (kernel 2.2.17-14) AND Solaris 5.8
These are the only two I have tested it on,
so I assume it is a platform independant bug.
I have created a small (19 line) example which includes
NO other files.
The program is quite simple. Note that it is basically
4 copies of the same 3 line program interlaced.. If you
replicate it further (ie: 100 copies of the same 3 line
program interlaced), then the ouput gets even stranger I
have made a meta program which generates them. I am
including it as well in b.c, but I doubt you'll need it.
There need to be 4 (or more) copies in the linux version
to show the error, but the solaris version shows it with
only 1 copy.
It was origionally a piece of code which was doing page
size calculations.. 4096 is the page size on linux, and
I was attempting to compute the number of pages needed for
a piece of data. Hoever I was able to decompose it down to
The output is correct when no optimizations are used,
but fail when -O2 is used.
Output is different on Linux and solaris when -O2 is used,
but both are incorrect.
I have included the .c file (a.c)
(no .i file, cause there are no includes)
and the output when using the -v option (a.v)
the a.v file was generated under linux.
gcc -O2 a.c
Um... dont use -O2 I guess... but that seems more like
a cheezy workarround than a fix.
Content-Type: application/octet-stream; name="b.c"
Content-Disposition: attachment; filename="b.c"
More information about the Gcc-bugs