[Bug c/17282] x = y++ + x++ operation wrongly implemented on solaris version

gaurav_har at rediffmail dot com gcc-bugzilla@gcc.gnu.org
Fri Sep 3 05:12:00 GMT 2004


------- Additional Comments From gaurav_har at rediffmail dot com  2004-09-03 05:12 -------
Hi,

It seems to me that this problem is different for what defined in other bug. 
Here we are assigning a value after adding and the variable with other 
constant, but instead of adding then incrementing the variable compiler is just 
incrementing the value. Behavior is different in Linux.

Code is:
x=20;
y=35;

x = y++ + x++;

For this expression compiler should first add x and y and then increment  x.
This expression should be broken like this.
x = x + y;
y++;
x++;

but compiler on Solaris is doing something like this:
temp = x++;
temp1 = y++;
x = x + y;
y = temp1;
x = temp; /* reassigning the variable with incremented value. This is wrong */

expected value of x here is 56, but its giving 21.

Same is working fine with Linux. this problem is there with Solaris and 
compilers cc and g++ also.

Regards,
Gaurav


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|DUPLICATE                   |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17282



More information about the Gcc-bugs mailing list