Bug 42052 - Incorrect code generated for cast to lvalue with post increment
Summary: Incorrect code generated for cast to lvalue with post increment
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.4.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-15 18:55 UTC by Raja Mukherji
Modified: 2009-11-15 19:02 UTC (History)
36 users (show)

See Also:
Host:
Target: i486-linux-gnu
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 Raja Mukherji 2009-11-15 18:55:51 UTC
gcc 4.4.1 generates incorrect code for the following type of expression:

void *P;

for (something) {
    ...
    *((*(int **)&P)++) = Value;
    ...
};

P remains unchanged throughout the loop.

This code worked correctly in earlier versions of gcc, last checked on gcc 4.3.2.

the following flags were used:
-std=gnu99 -fdata-sections -ffunction-sections -pipe -O2 -fomit-frame-pointer -w -D_GNU_SOURCE -fexpensive-optimizations
Comment 1 Andrew Pinski 2009-11-15 19:02:07 UTC
You are violating C/C++ aliasing rules.  You access a void* via a int*.

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