Bug 4888

Summary: incorrect code with -Ox, x >= 2
Product: gcc Reporter: jfran
Component: rtl-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: critical CC: gcc-bugs, rth
Priority: P2 Keywords: wrong-code
Version: 3.0.2   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: mem.c

Description jfran 2001-11-16 04:06:01 UTC
With optimizations enabled, "f=x; y=*(type*)&f;" reads garbage 
on 'y' unless 'type'=='char' (problem with memory alias?) 

"f=x; g(); y=*(type*)&f;" works fine if g() is not
inlined.

Release:
gcc >=2.96 <=3.0.2

How-To-Repeat:
Compile with -O0, execute.
Compile with -O2, execute.
Uncomment the commented line.
Test again.
Comment 1 Richard Henderson 2001-11-26 20:45:42 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.  See ISO/IEC 9899:1999 Section 6.9 paragraph 7.
    
    In summary, you may not access an object with anything other
    than its proper type.
Comment 2 Richard Henderson 2001-11-27 04:45:43 UTC
From: rth@gcc.gnu.org
To: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
  jfran@clip.dia.fi.upm.es, nobody@gcc.gnu.org
Cc:  
Subject: Re: optimization/4888: incorrect code with -Ox, x >= 2
Date: 27 Nov 2001 04:45:43 -0000

 Synopsis: incorrect code with -Ox, x >= 2
 
 State-Changed-From-To: open->closed
 State-Changed-By: rth
 State-Changed-When: Mon Nov 26 20:45:42 2001
 State-Changed-Why:
     Not a bug.  See ISO/IEC 9899:1999 Section 6.9 paragraph 7.
     
     In summary, you may not access an object with anything other
     than its proper type.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4888&database=gcc
Comment 3 Andrew Pinski 2005-06-05 09:33:10 UTC
Reopening to ..
Comment 4 Andrew Pinski 2005-06-05 09:33:34 UTC
Mark as a dup of bug 21920.

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