From mboxrd@z Thu Jan 1 00:00:00 1970 From: rossc@cs.colostate.edu To: gcc-gnats@gcc.gnu.org Subject: 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) Date: Wed, 25 Apr 2001 05:06:00 -0000 Message-id: <20010425120517.25305.qmail@sourceware.cygnus.com> X-SW-Source: 2001-04/msg00505.html List-Id: >Number: 2635 >Category: c >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) >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Apr 25 05:06:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Charles Ross (rossc@cs.colostate.edu) >Release: gcc version 2.95.2 19991024 (release) >Organization: >Environment: 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. >Description: 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 this code. 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. >How-To-Repeat: gcc -O2 a.c a.out >Fix: Um... dont use -O2 I guess... but that seems more like a cheezy workarround than a fix. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="b.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="b.c"