public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17282] New: x = y++ + x++ operation wrongly implemented on solaris version
@ 2004-09-02 12:07 gaurav_har at rediffmail dot com
  2004-09-02 12:36 ` [Bug c/17282] " schwab at suse dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gaurav_har at rediffmail dot com @ 2004-09-02 12:07 UTC (permalink / raw)
  To: gcc-bugs

x = y++ + x++ operation wrongly implemented on solaris version.

gcc Version:
chinar: /user/ggoel/Release/steel > gcc -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/specs
gcc version 2.8.1
chinar: /user/ggoel/Release/steel >

Program code:
#include<stdio.h>
main()
{
        int x=20,y=35;
        x = y++ + x++;
        printf("%d\n",x,y);
}
Output of program:
21

Expected output 56:

Comments: this problem is there with other compilers: cc and g++. Same problen 
is not apearing on Linux.

OS version:
chinar: /user/ggoel/Release/steel > uname -rsv
SunOS 5.6 Generic_105181-35
chinar: /user/ggoel/Release/steel > 

Other details:
chinar: /user/ggoel/Release/steel > gcc -v temp.c
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/specs
gcc version 2.8.1
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/cpp -lang-c -v -undef -
D__GNUC__=2 -D__GNUC_MINOR__=8 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -
D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -
Asystem(unix) -Asystem(svr4) -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine
(sparc) temp.c /var/tmp/ccava4ZP.i
GNU CPP version 2.8.1 (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/sparc-sun-solaris2.6/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/cc1 /var/tmp/ccava4ZP.i -
quiet -dumpbase temp.c -version -o /var/tmp/ccava4ZP.s
GNU C version 2.8.1 (sparc-sun-solaris2.6) compiled by GNU C version 2.8.1.
 /usr/ccs/bin/as -V -Qy -s -o /var/tmp/ccava4ZP1.o /var/tmp/ccava4ZP.s
/usr/ccs/bin/as: WorkShop Compilers 4.X dev 18 Sep 1996
 /usr/ccs/bin/ld -V -Y P,/usr/ccs/lib:/usr/lib -Qy /usr/local/lib/gcc-lib/sparc-
sun-solaris2.6/2.8.1/crt1.o /usr/local/lib/gcc-lib/sparc-sun-
solaris2.6/2.8.1/crti.o /usr/ccs/lib/values-Xa.o /usr/local/lib/gcc-lib/sparc-
sun-solaris2.6/2.8.1/crtbegin.o -L/usr/local/lib/gcc-lib/sparc-sun-
solaris2.6/2.8.1 -L/usr/local/sparc-sun-solaris2.6/lib -L/usr/ccs/bin -
L/usr/ccs/lib -L/usr/local/lib /var/tmp/ccava4ZP1.o -lgcc -lc -
lgcc /usr/local/lib/gcc-lib/sparc-sun-
solaris2.6/2.8.1/crtend.o /usr/local/lib/gcc-lib/sparc-sun-
solaris2.6/2.8.1/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.6-1.274
chinar: /user/ggoel/Release/steel >

-- 
           Summary: x = y++ + x++ operation wrongly implemented on solaris
                    version
           Product: gcc
           Version: 2.95.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gaurav_har at rediffmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/17282] x = y++ + x++ operation wrongly implemented on solaris version
  2004-09-02 12:07 [Bug c/17282] New: x = y++ + x++ operation wrongly implemented on solaris version gaurav_har at rediffmail dot com
@ 2004-09-02 12:36 ` schwab at suse dot de
  2004-09-03  5:12 ` gaurav_har at rediffmail dot com
  2004-09-03  5:23 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: schwab at suse dot de @ 2004-09-02 12:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2004-09-02 12:36 -------


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

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


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/17282] x = y++ + x++ operation wrongly implemented on solaris version
  2004-09-02 12:07 [Bug c/17282] New: x = y++ + x++ operation wrongly implemented on solaris version gaurav_har at rediffmail dot com
  2004-09-02 12:36 ` [Bug c/17282] " schwab at suse dot de
@ 2004-09-03  5:12 ` gaurav_har at rediffmail dot com
  2004-09-03  5:23 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: gaurav_har at rediffmail dot com @ 2004-09-03  5:12 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/17282] x = y++ + x++ operation wrongly implemented on solaris version
  2004-09-02 12:07 [Bug c/17282] New: x = y++ + x++ operation wrongly implemented on solaris version gaurav_har at rediffmail dot com
  2004-09-02 12:36 ` [Bug c/17282] " schwab at suse dot de
  2004-09-03  5:12 ` gaurav_har at rediffmail dot com
@ 2004-09-03  5:23 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-03  5:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-03 05:23 -------
Nope x = x++; is undefined so is x = 1 + x++; or x = y++ + x++;, you are modifing x twice in 
without a sequence point inbetween.

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

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


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-09-03  5:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-02 12:07 [Bug c/17282] New: x = y++ + x++ operation wrongly implemented on solaris version gaurav_har at rediffmail dot com
2004-09-02 12:36 ` [Bug c/17282] " schwab at suse dot de
2004-09-03  5:12 ` gaurav_har at rediffmail dot com
2004-09-03  5:23 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).