public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9062: gcc 3.2.0, 3.2.1 optimization bug with postincrement
@ 2002-12-26 16:56 andrej.filipcic
0 siblings, 0 replies; 2+ messages in thread
From: andrej.filipcic @ 2002-12-26 16:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 9062
>Category: c++
>Synopsis: gcc 3.2.0, 3.2.1 optimization bug with postincrement
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Dec 26 16:56:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: andrej.filipcic@ijs.si
>Release: unknown-1.0
>Organization:
>Environment:
redhat 8.0
>Description:
The following code miscompiles with "g++ -O2" gcc-3.2.0, gcc-3.2.1. "-O0,1,3" gives correct results. Output of "-O2"
is "bcdefgh" instead of "abcdefgh"
Equivalent in c only works with "-O1".
----------------------
#include <iostream>
using namespace std;
void str2lower(char *p) {
while(*p) *p++=tolower(*p);
}
int main() {
char str[]="Abcdefgh";
str2lower(str);
cout<<str<<endl;
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c++/9062: gcc 3.2.0, 3.2.1 optimization bug with postincrement
@ 2002-12-30 13:29 reichelt
0 siblings, 0 replies; 2+ messages in thread
From: reichelt @ 2002-12-30 13:29 UTC (permalink / raw)
To: andrej.filipcic, gcc-bugs, gcc-prs, nobody
Synopsis: gcc 3.2.0, 3.2.1 optimization bug with postincrement
State-Changed-From-To: open->closed
State-Changed-By: reichelt
State-Changed-When: Mon Dec 30 13:29:45 2002
State-Changed-Why:
Not a bug.
You're invoking undefined behaviour (the compiler may
evaluate the left hand side and right hand side of
*p++=tolower(*p);
in any order - which changes with optimization.)
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9062
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-12-30 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-26 16:56 c++/9062: gcc 3.2.0, 3.2.1 optimization bug with postincrement andrej.filipcic
2002-12-30 13:29 reichelt
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).