Bug 33043 - Miscompiled statement a[i] = (a[i]++) % x;
Summary: Miscompiled statement a[i] = (a[i]++) % x;
Status: RESOLVED DUPLICATE of bug 11751
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-10 10:50 UTC by Gregor Jasny
Modified: 2007-08-10 12:02 UTC (History)
55 users (show)

See Also:
Host: i486-pc-linux-gnu
Target: i486-pc-linux-gnu
Build: i486-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Simple testcase (165 bytes, text/plain)
2007-08-10 10:51 UTC, Gregor Jasny
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gregor Jasny 2007-08-10 10:50:38 UTC
When the following program is compiled with gcc the output of the array-value is 1 2 3 4 5 6. Icc and cl produce the output 1 2 3 4 1 2. If the arrray is susbtituted by a simple scalar, the gcc output is 1 2 3 4 1 2, too.

I don't know if the statement if even valid and behavior-defined C code. If it's not, then gcc maybe should warn somehow.

Thanks,
 Gregor

PS: This hapens with gcc-snapshot 20070720-1, too.
Comment 1 Gregor Jasny 2007-08-10 10:51:23 UTC
Created attachment 14049 [details]
Simple testcase
Comment 2 Gregor Jasny 2007-08-10 12:02:07 UTC
I've found:
http://c-faq.com/expr/seqpoints.html

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