Bug 8302 - Pointer casting causes ++ to be ignored when optimizing
Summary: Pointer casting causes ++ to be ignored when optimizing
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2002-10-21 09:46 UTC by noaml
Modified: 2005-11-11 07:22 UTC (History)
51 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description noaml 2002-10-21 09:46:01 UTC
unsigned char *p;
unsigned char x;
....
*(*((unsigned char **)(&p)))++ = x;
as a side effect, p should be incremented. Sometimes, in optimized, it is not.

Release:
gcc version 3.3 20021019 (experimental)

Environment:
Intel 386. RH 7.3. kernel 2.4.18-3

How-To-Repeat:
gcc -O2 main.c
a.out
This source is in standard testcase format, and will call abort() upon failure.
Comment 1 noaml 2002-10-21 09:46:01 UTC
Fix:
Changing the code to 
*(*((unsigned char **)(&p))) = x;
p += sizeof(x);
Comment 2 Wolfgang Bangerth 2002-12-06 12:18:13 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: There is no self-contained testcase in this report. Do you
    still have it, so that we can take a look at it?
    
    Thanks
      Wolfgang
Comment 3 Wolfgang Bangerth 2002-12-10 08:34:27 UTC
State-Changed-From-To: feedback->closed
State-Changed-Why: Aliasing violation, as discussed in 
      http://gcc.gnu.org/ml/gcc-bugs/2002-10/msg00886.html
Comment 4 Andrew Pinski 2005-11-10 04:01:38 UTC
Reopening to ...
Comment 5 Andrew Pinski 2005-11-10 04:01:53 UTC
Close as a dup of bug 21920.

*** This bug has been marked as a duplicate of 21920 ***
Comment 6 philippe_ribet 2005-11-11 07:22:24 UTC
Removed this email, someone added it by error.