Bug 13411 - segmentation fault occurs in correct code - optimisation problem at O2
Summary: segmentation fault occurs in correct code - optimisation problem at O2
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: wrong-code
Depends on:
Reported: 2003-12-16 16:01 UTC by Michael Cieslinski
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: powerpc-linux
Target: powerpc-linux
Known to work:
Known to fail:
Last reconfirmed:

not pre-processed source file (7.88 KB, text/plain)
2003-12-16 16:05 UTC, Michael Cieslinski
preprocessed source file (25.15 KB, text/plain)
2003-12-16 16:06 UTC, Michael Cieslinski

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Cieslinski 2003-12-16 16:01:34 UTC
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
Comment 1 Michael Cieslinski 2003-12-16 16:05:39 UTC
Created attachment 5339 [details]
not pre-processed source file
Comment 2 Michael Cieslinski 2003-12-16 16:06:15 UTC
Created attachment 5340 [details]
preprocessed source file
Comment 3 Andrew Pinski 2004-01-28 17:32:58 UTC
Can you try a snapshot of 3.4, I cannot reproduce this with a target which adds -mabi=
altivec by default, can you also try that option?
Comment 4 Andrew Pinski 2004-02-06 01:59:36 UTC
You are violating aliasing rules:
  MTstS8  = (VS8  *) APool;
  MTstU8  = (VU8  *) APool;
  MTstS16 = (VS16 *) APool;
  MTstU16 = (VU16 *) APool;
  MTstS32 = (VS32 *) APool;
  MTstU32 = (VU32 *) APool;
  MTstU32 = (VU32 *) APool;
  MTstF   = (VecF *) APool;
  ETstU8  = (U8   *) APool;
Comment 5 Andrew Pinski 2005-06-05 08:39:43 UTC
Reopening to ...
Comment 6 Andrew Pinski 2005-06-05 08:40:02 UTC
Mark as a dup of bug 21920.

*** This bug has been marked as a duplicate of 21920 ***