Bug 1039 - cout does not give correct output with pointer ++
Summary: cout does not give correct output with pointer ++
Status: RESOLVED DUPLICATE of bug 11751
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 2.95.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-12-11 08:16 UTC by lid
Modified: 2005-04-20 02:47 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
bug.tar (6.76 KB, application/octet-stream)
2003-05-21 15:16 UTC, lid
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lid 2000-12-11 08:16:01 UTC
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
Comment 1 James Dennett 2001-02-20 18:31:12 UTC
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.
Comment 2 James Dennett 2001-02-21 02:31:12 UTC
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
Comment 3 Andrew Pinski 2005-04-20 02:47:09 UTC
Reopening to ...
Comment 4 Andrew Pinski 2005-04-20 02:47:29 UTC
Mark as a dup of bug 11751.

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