User account creation filtered due to spam.

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
Keywords: wrong-code
Depends on:
Reported: 2002-10-21 09:46 UTC by noaml
Modified: 2005-11-11 07:22 UTC (History)
51 users (show)

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


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.

gcc version 3.3 20021019 (experimental)

Intel 386. RH 7.3. kernel 2.4.18-3

gcc -O2 main.c
This source is in standard testcase format, and will call abort() upon failure.
Comment 1 noaml 2002-10-21 09:46:01 UTC
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?
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
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.