public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/8613: -O3 optimisation of ++ generates wrong code
@ 2002-11-22 11:23 mark.odonohue
0 siblings, 0 replies; 2+ messages in thread
From: mark.odonohue @ 2002-11-22 11:23 UTC (permalink / raw)
To: gcc-gnats
>Number: 8613
>Category: optimization
>Synopsis: -O3 optimisation of ++ generates wrong code
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Nov 17 05:46:06 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: mark.odonohue@cytopia.com.au
>Release: gcc 3.2
>Organization:
>Environment:
mandrake linux 9.0
>Description:
In the provided code,
*dpb++ = strlen(userName)
dpb is incorrectly incremented by two bytes, not one.
The output buffer should result in:
1, 35, 6, 'sysdba'.
Instead it results in:
1, 35, 6, x, 'sysdba'
where x is random.
Tracing in gdb shows that dpb is incremented by a value of two.
>How-To-Repeat:
g++ -O2 -march=i686 -fPIC test1.cpp
./a.out 1
>Fix:
-O1 seems to work.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test1.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test1.cpp"
CgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RyaW5n
PgojaW5jbHVkZSA8aW9zdHJlYW0+CgppbnQgbWFpbihpbnQgYXJnYywgY2hhciogYXJndltdKSB7
CgogIGludCBhdmFsdWUgPSAwOwogIGNoYXIgZHBiX2J1ZmZlclsyNTZdLCAqZHBiOwoKICBjaGFy
IHVzZXJOYW1lMVsyNTZdOwogIGNvbnN0IGNoYXIqIHVzZXJOYW1lID0gInN5c2RiYSI7CiAgY29u
c3QgY2hhciogcGFzc3dkID0gIm1hc3RlcmtleSI7CgogIHN0cmNweSh1c2VyTmFtZTEsIHVzZXJO
YW1lKTsKICAKICBhdmFsdWUgPSBhdG9pKGFyZ3ZbMV0pOwogIGRwYiA9IGRwYl9idWZmZXI7Cgog
ICpkcGIrKyA9IDB4MTsKICAqZHBiKysgPSAweDM1OwogIC8vcHJpbnRmKCIleFxuIiwgZHBiKTsK
ICBpZiAoIGF2YWx1ZSkgewogICAgICpkcGIrKyA9IHN0cmxlbih1c2VyTmFtZTEpOwogIC8vcHJp
bnRmKCIleFxuIiwgZHBiKTsKICAgICBmb3IgKGNoYXIqIHA9dXNlck5hbWUxOyAqcDspIHsKICAg
ICAgICAqZHBiKysgPSAqcCsrOwogICAgIH0KICB9CiAgCiAgZm9yIChpbnQgaSA9MDsgaSA8IDEw
OyBpKyspIHsKICAgICAgcHJpbnRmKCIlZCwgJWMsIGNoYXIgPSAleFxuIiwgaSwgZHBiX2J1ZmZl
cltpXSwgZHBiX2J1ZmZlcltpXSk7CiAgfQogIC8vcHJpbnRmKCJjaGFyID0gJWNcbiIsIGRwYl9i
dWZmZXJbMl0pOwoKICByZXR1cm4gMDsKfQoK
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: optimization/8613: -O3 optimisation of ++ generates wrong code
@ 2002-11-22 13:33 Mark O'Donohue
0 siblings, 0 replies; 2+ messages in thread
From: Mark O'Donohue @ 2002-11-22 13:33 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/8613; it has been noted by GNATS.
From: "Mark O'Donohue" <mark.odonohue@cytopia.com.au>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, mark.odonohue@cytopia.com.au,
gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:
Subject: Re: optimization/8613: -O3 optimisation of ++ generates wrong code
Date: Mon, 18 Nov 2002 12:28:45 +1100
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8613
confirmed on redhat 8.0
Also it seem tied up with i686 architecture.
Since on redhat 8.0 gcc 3.2:
g++ -O2 test1.cpp
works:
and on mandrak9.0 gcc 3.2
g++ -O2 -march=i386 test1.cpp
also works.
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-11-18 1:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-22 11:23 optimization/8613: -O3 optimisation of ++ generates wrong code mark.odonohue
2002-11-22 13:33 Mark O'Donohue
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).