public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/7884: code compiled with optimization flag causes segmentation violation on powerpc
@ 2002-09-11 2:19 nathan
0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-09-11 2:19 UTC (permalink / raw)
To: aloeff, gcc-bugs, gcc-prs, nobody
Synopsis: code compiled with optimization flag causes segmentation violation on powerpc
State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Wed Sep 11 02:18:59 2002
State-Changed-Why:
This is not a bug, but I expected a warning (which we used
to give). '(char *)foo' is an rvalue. the call through
to 'char *&ref' binds an rvalue to a non-const reference.
That is ill-formed. It binds to a temporary copy, thus
the pointer seen by the function is not the object
you cast.
The correct solution is the cast to an lvalue,
'(char *&)foo'
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7884
^ permalink raw reply [flat|nested] 2+ messages in thread
* optimization/7884: code compiled with optimization flag causes segmentation violation on powerpc
@ 2002-09-11 1:36 aloeff
0 siblings, 0 replies; 2+ messages in thread
From: aloeff @ 2002-09-11 1:36 UTC (permalink / raw)
To: gcc-gnats
>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=
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-09-11 9:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-11 2:19 optimization/7884: code compiled with optimization flag causes segmentation violation on powerpc nathan
-- strict thread matches above, loose matches on Subject: below --
2002-09-11 1:36 aloeff
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).