public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: mark.odonohue@cytopia.com.au
To: gcc-gnats@gcc.gnu.org
Subject: optimization/8613: -O3 optimisation of ++ generates wrong code
Date: Fri, 22 Nov 2002 11:23:00 -0000	[thread overview]
Message-ID: <20021117133942.7556.qmail@sources.redhat.com> (raw)


>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


             reply	other threads:[~2002-11-17 13:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-22 11:23 mark.odonohue [this message]
2002-11-22 13:33 Mark O'Donohue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021117133942.7556.qmail@sources.redhat.com \
    --to=mark.odonohue@cytopia.com.au \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).