Bug 762 - can not calculate x *=x++ correctly on GNU 2.8.1 in sparc-sun-solaris2.6 environment
can not calculate x *=x++ correctly on GNU 2.8.1 in sparc-sun-solaris2.6 envi...
Status: RESOLVED DUPLICATE of bug 11751
Product: gcc
Classification: Unclassified
Component: c
unknown
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2000-11-09 15:16 UTC by chuchunxin
Modified: 2005-11-10 03:17 UTC (History)
40 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 chuchunxin 2000-11-09 15:16:01 UTC
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
Comment 1 chuchunxin 2000-11-09 15:16:01 UTC
Fix:
Not a bug; it is undefined behaviour.
Comment 2 Neil Booth 2000-11-09 15:48:38 UTC
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.
Comment 3 Neil Booth 2000-11-09 23:48:38 UTC
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
Comment 4 Andrew Pinski 2005-11-10 03:17:39 UTC
Reopening to ...
Comment 5 Andrew Pinski 2005-11-10 03:17:55 UTC
Mark as a dup of bug 11751.

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