Bug 4888 - incorrect code with -Ox, x >= 2
Summary: incorrect code with -Ox, x >= 2
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.0.2
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2001-11-16 04:06 UTC by jfran
Modified: 2005-06-05 09:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
mem.c (142 bytes, application/octet-stream)
2003-05-21 15:17 UTC, jfran
Details

Note You need to log in before you can comment on or make changes to this bug.
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 ***