User account creation filtered due to spam.

Bug 16887 - Bad assignment in "int i=1; i=i++;"
Summary: Bad assignment in "int i=1; i=i++;"
Status: RESOLVED DUPLICATE of bug 11751
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-05 14:09 UTC by Kristoffer Sokolowski
Modified: 2005-07-23 22:49 UTC (History)
1 user (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 Kristoffer Sokolowski 2004-08-05 14:09:54 UTC
gcc -v:
Reading specs from /opt/GCC341/lib/gcc/sparc-sun-solaris2.6/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --prefix=/opt/GCC341 --with-as=/usr/ccs/bin/as --with-
ld=/usr/ccs/bin/ld --disable-libgcj --enable-languages=c,c++,objc
Thread model: posix
gcc version 3.4.1

uname -srv:
SunOS 5.6 Generic_105181-11

Comments:
The not normally used expression:
 int i=1; 
 i=i++;
will yield i==1, but should yield i==2. 
This does not occur in GCC v.2.8.1 nor in Microsoft VC++. 
Could be a problem in another assignment situations
Comment 1 Richard Earnshaw 2004-08-05 14:21:02 UTC
Not a bug.  Think sequence points...
Comment 2 Kristoffer Sokolowski 2004-08-05 14:41:20 UTC
(In reply to comment #1)
> Not a bug.  Think sequence points...
I'm not sure what you mean by that, but
I still think it is a bug, because operator ++ has higher precedence 
over =.
Comment 3 Wolfgang Bangerth 2004-08-05 14:54:42 UTC
No, it's not a bug. You can't modify a variable twice in one 
expression. That's what you're trying to do, though, with the ++ 
and the assignment. 
 
Take a look at any of PR 11363, PR 11751, PR 12552, PR 13403,  
PR 14417, PR 15012, PR 15103. 
 
W. 
Comment 4 Wolfgang Bangerth 2004-08-13 15:45:23 UTC
Reopen to mark as a duplicate of... 
Comment 5 Wolfgang Bangerth 2004-08-13 15:46:07 UTC
...PR 11751. 

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