[Bug optimization/13411] New: segmentation fault occurs in correct code - optimisation problem at O2

micis at gmx dot de gcc-bugzilla@gcc.gnu.org
Tue Dec 16 16:07:00 GMT 2003

A small function named SM33S destroys local variables which lead to an
segmentation fault when called twice.
This error occurs only when some printf statements are after the declaration
of variables and not at the beginning of the function.
Also the function works when the adresses of data accesses are checked.
It seems to be an optimisation problem since it occurs only at -O2 or higher.
At -O0 the compiler generates an internal compiler error, but I will submit
this in a different bug report.

This program is a test program for developing an altivec function. The 
same operation is implemented in different ways (with and without altivec
code) and the results are compared.
If the altivec implementation is removed or returns immediately, SM33S
alters one of the loacal variables in main() but no segmentation error
I have tried to narrow this bug down, but if you change to much on that 
program, the error will not occur.

output from gcc -v:

Reading specs from /usr/lib/gcc-lib/powerpc-linux/3.3.2/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared 
--with-system-zlib --enable-nls --without-included-gettext 
--enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm 
--enable-java-awt=xlib --enable-objc-gc --disable-multilib powerpc-linux
Thread model: posix
gcc version 3.3.2 (Debian)

gcc command line:

gcc -g -o matbug matbug.cpp -mcpu=7450 -maltivec -O2 -lstdc++ -Wall  -pedantic -
lefence -save-temps -fverbose-asm

           Summary: segmentation fault occurs in correct code - optimisation
                    problem at O2
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: micis at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: powerpc-linux
GCC target triplet: powerpc-linux


More information about the Gcc-bugs mailing list