public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17095] New: ++ opertator and + operator is not working together.
@ 2004-08-19  7:00 asokumar at gmail dot com
  2004-08-19  8:01 ` [Bug c/17095] " reichelt at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: asokumar at gmail dot com @ 2004-08-19  7:00 UTC (permalink / raw)
  To: gcc-bugs

main()
{
	int x=20,y=35;
	printf("1:%d%d\n",x,y);
	x=y++ + x++; //This operation is not working
	printf("2:%d%d\n",x,y);
	y= ++y + ++x;
	printf("3:%d%d\n",x,y);
}
	
If you compile the following program it gives  following output.

gcc(3.3.2) - Wrong output
------------
1:2035
2:2136
3:2259

Ideal output should be
----------------------
1:2035
2:5636
3:5794

-- 
           Summary: ++ opertator and + operator is not working together.
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: asokumar at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c/17095] ++ opertator and + operator is not working together.
  2004-08-19  7:00 [Bug c/17095] New: ++ opertator and + operator is not working together asokumar at gmail dot com
@ 2004-08-19  8:01 ` reichelt at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-19  8:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-08-19 08:01 -------
This is not a bug in the compiler, but in your code.
Your code triggers undefined behavior because there's no sequence
point in "x=y++ + x++". An even shorter example would be "x=x++".

*** 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=17095


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

end of thread, other threads:[~2004-08-19  8:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-19  7:00 [Bug c/17095] New: ++ opertator and + operator is not working together asokumar at gmail dot com
2004-08-19  8:01 ` [Bug c/17095] " reichelt 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).