Bug 6164 - incorrect code above optimization -O1
Summary: incorrect code above optimization -O1
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.0.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: wrong-code
Depends on:
Reported: 2002-04-03 17:06 UTC by rarob
Modified: 2005-06-05 09:41 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:

myc.c (1.01 KB, application/octet-stream)
2003-05-21 15:17 UTC, rarob

Note You need to log in before you can comment on or make changes to this bug.
Description rarob 2002-04-03 17:06:01 UTC
The program is to test functions that convert between the VAX D double precision datatype and the IEEE double precision datatype (assuming a big-endian host).  The executable produces incorrect results for optimization levels above -O1.

The program will show the 8 bytes of the VAX double precision number, the resultant IEEE value, the 8 bytes of the IEEE double precision number, then convert back to the VAX double and show the 8 bytes.  If it doesn't get what it started with a message is displayed.

gcc 3.0.4

System: Linux rmsibook.zai.com 2.4.10-12a #1 Tue Oct 9 04:49:39 EDT 2001 ppc unknown	

This works:
	compile ->  gcc -Wall myc.c -o myc
	execute ->  ./myc
     compile ->  gcc -Wall -O1 myc.c -o myc
     execute ->  ./myc

These produce incorrect executable code
     compile -> gcc -Wall -O2 myc.c -o myc
     execute -> ./myc
     and so on thru compiling with -O5

NOTE:  We have seen a very similar problem on a Athelon Linux box under Redhat 7.x  *except* the the incorrect code only
appears with running with optimization level -O2.  The problem existed with gcc 3.0.3 as well.
Comment 1 Richard Henderson 2002-04-04 02:41:22 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.  This code violates ISO C aliasing rules.
    With gcc, one can use a union, but even this isn't
    strictly portable.
Comment 2 Andrew Pinski 2005-06-05 09:40:47 UTC
Reopening to ...
Comment 3 Andrew Pinski 2005-06-05 09:41:11 UTC
Mark as a dup of bug 21920.

*** This bug has been marked as a duplicate of 21920 ***