This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/7884: code compiled with optimization flag causes segmentation violation on powerpc

>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
>Originator:     Andreas Loeffler
>Release:        3.1 and 3.2
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
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);

powerpc-linux-g++ -o test-opt
without optimization myData gets assigned a value

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

Content-Type: application/octet-stream; name=""
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=""


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]