when p is a int pointer, "cout<<p<<*p<<p++<<*p++<<endl;" will not give a correct output. p was affected by the later p++. Only with cout<<p<<*p;cout<<p++<<*p++; will give correct output. This problem was only found on the Linux OS with a intel machine. The same code compiled in a SUN workstation will give the right output. Release: 2.95.3 19991030 Environment: Linux pvil-a-070.resnet.purdue.edu 2.2.17-21mdk #1 Thu Oct 5 13:16:08 CEST 2000 i686 unknown
State-Changed-From-To: open->closed State-Changed-Why: Not a bug, only a misunderstanding of C++ sequence point rules. The attached code invokes undefined behavior.
From: jdennett@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, lid@ecn.purdue.edu, nobody@gcc.gnu.org Cc: Subject: Re: c++/1039 Date: 21 Feb 2001 02:31:12 -0000 Synopsis: cout does not give correct output with pointer ++ State-Changed-From-To: open->closed State-Changed-By: jdennett State-Changed-When: Tue Feb 20 18:31:12 2001 State-Changed-Why: Not a bug, only a misunderstanding of C++ sequence point rules. The attached code invokes undefined behavior. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=1039&database=gcc
Reopening to ...
Mark as a dup of bug 11751. *** This bug has been marked as a duplicate of 11751 ***