This is the mail archive of the gcc-help@gcc.gnu.org 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]

Re: [gcc-4.3.1][c++] weird segfault with -O3 in constructor of a global object


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 compiled it with -g
>   g++ -O3 -g test.cpp -o test
> and gdb gave
> {{{
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000400553 in global constructors keyed to foo () at test.cpp:2
> 2	  vector() : x(0), y(0), z(0) { }
> (gdb) bt
> #0  0x0000000000400553 in global constructors keyed to foo () at test.cpp:2
> #1  0x0000000000400636 in __do_global_ctors_aux ()
> #2  0x000000000040041b in _init ()
> #3  0x00007fbf690ee8c0 in ?? () from /usr/lib/libstdc++.so.6
> #4  0x00000000004005c5 in __libc_csu_init ()
> #5  0x00007fbf688ca382 in __libc_start_main () from /lib/libc.so.6
> #6  0x0000000000400479 in _start ()
> (gdb)
> }}}
>
> Can anyone confirm this?
>
> Thanks,
>  -- Maik

I debootstraped ubuntu hardy amd64 to a partition, did boot into and compiled 
gcc-4.3.1.  Same segfault as above.  I file a bug report.

-- Maik


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