This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17282] x = y++ + x++ operation wrongly implemented on solaris version
- From: "gaurav_har at rediffmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Sep 2004 05:12:41 -0000
- Subject: [Bug c/17282] x = y++ + x++ operation wrongly implemented on solaris version
- References: <20040902120650.17282.gaurav_har@rediffmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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