This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: [gcc-4.3.1][c++] weird segfault with -O3 in constructor of a global object
- From: Maik Beckmann <beckmann dot maik at googlemail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 26 Jun 2008 11:53:17 +0200
- Subject: Re: [gcc-4.3.1][c++] weird segfault with -O3 in constructor of a global object
- References: <200806251909.14066.beckmann.maik@googlemail.com>
Am Mittwoch 25 Juni 2008 19:09:13 schrieb Maik Beckmann:
> Hello,
>
> This code
> {{{
> struct vector {
> vector() : x(0), y(0), z(0) { }
> float x,y,z;
> };
>
> struct Foo {
> int dummy; // commenting this out makes it run perfectly
> vector array_of_vectors[4];
> };
>
> Foo foo;
>
> int main() { }
> }}}
> compiled with
> g++ -O3 test.cpp -o test
> segaults on my x86-64 linux box.
I'm running arch-linux x86-64.
I compiled the vanilla gcc-4.3.1 sources
{{{
maik@localhost:~/workspace/tester/gcc43$
LC_ALL=C /var/abs/local/gcc/gcc-4.3.1/stage/bin/g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured
with: ../configure --prefix=/var/abs/local/gcc/gcc-4.3.1/stage --enable-languages=c++ --disable-multilib --with-optimization=generic
Thread model: posix
gcc version 4.3.1 (GCC)
}}}
which give me the same segfault as with the gcc from the arch-linux
repositories:
{{{
maik@localhost:~$ LC_ALL=C g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured
with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix --mandir=/usr/share/man --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic
Thread model: posix
gcc version 4.3.1 (GCC)
}}}
This thread at the arch-general list
http://thread.gmane.org/gmane.linux.arch.general/16677
shows that on x86-32 it works fine while on x86-64 the segfault happens.
All I wait for filing a bug report is someone out there saying that vanilla
gcc-4.3.1 on his/her debian/ubuntu/redhat/fedora x86-64 (aka. amd64) box
causes the same segfault with -O3 on the code I posted.
Best,
-- Maik