User account creation filtered due to spam.

Bug 3046 - code incorrectly removed
Summary: code incorrectly removed
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 2.96
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2001-06-04 04:46 UTC by boris
Modified: 2005-06-05 09:51 UTC (History)
2 users (show)

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


Attachments
float.i.gz (3.78 KB, application/x-gzip )
2003-05-21 15:17 UTC, boris
Details

Note You need to log in before you can comment on or make changes to this bug.
Description boris 2001-06-04 04:46:01 UTC
The code below (float.c) fills in a float `f' with
1.00000 by accessing it as an array `fp' of two unsigned integers, and
storing the appropriate value in each element of the array.  The value
printed should therefore be 1.00000, and this is what happens when
compiling without optimization options.  With -O2 and above, the value
printed is 2.0000.  Qualifying both `f' and `fp' as volatile seems to
eliminate the wrong behavior.

Release:
gcc version 2.96 20000731

Environment:
Red Had Linux 7.1, kernel 2.4.2-2 i686 unknown

How-To-Repeat:
gcc -O3 float.c -o float ; ./float
Comment 1 boris 2001-06-04 04:46:01 UTC
Fix:
Not using optimizations above -O, or adding volatile to 
f and fp.  However, this is not feasible in my application:
the error may appear in many places.
Comment 2 Richard Henderson 2002-04-02 01:21:49 UTC
State-Changed-From-To: open->closed
State-Changed-Why: This code violates ISO C aliasing rules (paragraph 6.5/7).
    Use a union instead.
Comment 3 Andrew Pinski 2005-06-05 09:50:25 UTC
Reopening to ...
Comment 4 Andrew Pinski 2005-06-05 09:51:57 UTC
Mark as a dup of bug 21920.

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