x = 2; x *= x++; what is the value of x? It should be 5, but in the workstation I can only get 3. Release: 2.8.1 Environment: sun solaris 2.6 How-To-Repeat: Just do a calculation on the above expression
Fix: Not a bug; it is undefined behaviour.
State-Changed-From-To: open->closed State-Changed-Why: Not a bug; it is undefined behaviour. >> what is the value of x? Exactly! You might want to use x *= x or x = x * x + 1 depending upon what you're trying to do.
From: neil@gcc.gnu.org To: chuchunxin@hotmail.com, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c/762 Date: 9 Nov 2000 23:48:38 -0000 Synopsis: can not calculate x *=x++ correctly on GNU 2.8.1 in sparc-sun-solaris2.6 environment State-Changed-From-To: open->closed State-Changed-By: neil State-Changed-When: Thu Nov 9 15:48:38 2000 State-Changed-Why: Not a bug; it is undefined behaviour. >> what is the value of x? Exactly! You might want to use x *= x or x = x * x + 1 depending upon what you're trying to do. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=762&database=gcc
Reopening to ...
Mark as a dup of bug 11751. *** This bug has been marked as a duplicate of 11751 ***