User account creation filtered due to spam.

Bug 3324 - wrong operator priority
Summary: wrong operator priority
Status: RESOLVED DUPLICATE of bug 11751
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2001-06-21 04:36 UTC by arminu
Modified: 2005-04-20 02:55 UTC (History)
2 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 arminu 2001-06-21 04:36:01 UTC
the prefix increment operator is not correctly evaluated in the following code:

int a[8];
int i = 4;
a[i] = ++i;

the last line is evaluated as 
a[4] = 5;
instead of 
a[5] = 5;

Release:
2.95-2, 2.95-3, 2.96, 3.0.1 20010620

Environment:
mingw port (2.95-2, 2.95-3), RedHat Linux 7.1 gcc compiler (2.96-??), CodeSourcery online test compilation(3.0.1 20010620 )

How-To-Repeat:
void test(void)
{
int a[8] = {0,0,0,0,0,0,0,0};
int i = 4;
a[i] = ++i;
printf("\na[4] = %d\na[5] = %d\n", a[4], a[5]);
}
Comment 1 Neil Booth 2001-06-21 04:59:59 UTC
State-Changed-From-To: open->closed
State-Changed-Why: This is not a bug - your code has undefined behaviour
    as there is no sequence point between the two uses.
Comment 2 Andrew Pinski 2005-04-20 02:55:05 UTC
Reopening to ...
Comment 3 Andrew Pinski 2005-04-20 02:55:25 UTC
Mark as a dup of bug 11751.

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