public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: aloeff@de.ibm.com
To: gcc-gnats@gcc.gnu.org
Subject: optimization/7884: code compiled with optimization flag causes segmentation violation on powerpc
Date: Wed, 11 Sep 2002 01:36:00 -0000	[thread overview]
Message-ID: <20020911082742.8812.qmail@sources.redhat.com> (raw)


>Number:         7884
>Category:       optimization
>Synopsis:       code compiled with optimization flag causes segmentation violation on powerpc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 11 01:36:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Andreas Loeffler
>Release:        3.1 and 3.2
>Organization:
>Environment:
redhat 7.1
[lefty@trinity - 09:34am: ~]$ powerpc-linux-gcc -v
Reading specs from /opt/fsp/i586-pc-linux-gnu/local/lib/gcc-lib/powerpc-linux/3.2/specs
Configured with: ../configure --host=i586-pc-linux-gnu --target=powerpc-linux --prefix=/opt/fsp/i586-pc-linux-gnu/local --enable-shared --enable-languages=c,c++,f77 --with-headers=/opt/fsp/powerpc-linux/include --with-libs=/opt/fsp/powerpc-linux/lib --with-cpu=403 --without-fp
Thread model: posix
gcc version 3.2
>Description:
We have encountered problems compiling our code with the -Os
flag (and -O, -O2, -O3) and attempting to run on the hardware.
We've tracked it down to one particular 
scenario that causes the problem

If you have a function defined like this

        int f(char*& data);

and some code that calls it that looks like this

        rc = f((char*)myData);
        x = myData->value;

The value myData does not get set and we get a segmentation
violation. To fix it, it needs to be changed to

        rc = f((char*&)myData);

>How-To-Repeat:
powerpc-linux-g++ -o test-opt test-opt.cc
without optimization myData gets assigned a value

powerpc-linux-g++ -O -o test-opt test-opt.cc
powerpc-linux-g++ -Os -o test-opt test-opt.cc
powerpc-linux-g++ -O3 -o test-opt test-opt.cc
with optimization myData becomes a null pointer which
can cause seg faults
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test-opt.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test-opt.cc"

I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIGYoY2hhciomIGRhdGEpCnsKICAgIGNoYXIqIHRtcCA9
IG5ldyBjaGFyWzI1Nl07CiAgICBkYXRhID0gdG1wOwp9CgoKaW50IG1haW4gKGludCBhcmdjLCBj
aGFyICphcmd2W10pCnsKICAgIHZvaWQqIG15RGF0YSA9IDA7CgogICAgLy9mKChjaGFyKiYpbXlE
YXRhKTsKICAgIGYoKGNoYXIqKW15RGF0YSk7CgogICAgcHJpbnRmKCJteURhdGEoMSkgPSAleFxu
IixteURhdGEpOwoKICAgIHJldHVybiAwOwp9Cgo=


             reply	other threads:[~2002-09-11  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-11  1:36 aloeff [this message]
2002-09-11  2:19 nathan

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=20020911082742.8812.qmail@sources.redhat.com \
    --to=aloeff@de.ibm.com \
    --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).