gcc 4.6.0 weekly snapshot 20110312 $ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.0/lto-wrapper Target: x86_64-linux-gnu Configured with: ../configure --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --without-included-gettext --enable-threads=posix --program-suffix=-4.6 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=core2 --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-cpu=core2 Thread model: posix gcc version 4.6.0 20110312 (experimental) (GCC) With the following code: #include <complex> void test () { std::complex<double> array[] = { std::complex<double>(0,1) }; } I get: $ g++ -std=c++0x -c complex_test.cc -o complex_test.o complex_test.cc: In function ‘void test()’: complex_test.cc:4:62: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. The code compiles fine without -std=c++0x, and it is also fine with gcc 4.5.2.
confirmed
Reduced testcase: struct C { constexpr C (int x) : c (x) {} int c; }; void foo () { C a[] = { C (0) }; }
Regressed (expectedly) with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166167 The problem seems to be that the middle-end relies on indexes being filled in in ctors for arrays, but the C++ FE in this case doesn't fill them in. For POD arrays the indexes are added by process_init_constructor_array, but that isn't called in this case (both because check_initializer will do: /* Don't call digest_init; it's unnecessary and will complain about aggregate initialization of non-aggregate classes. */ flags |= LOOKUP_ALREADY_DIGESTED; and also because it is called only for: if (BRACE_ENCLOSED_INITIALIZER_P (init) && !TYPE_NON_AGGREGATE_CLASS (type)) return process_init_constructor (type, init);
Author: jason Date: Wed Mar 16 20:03:12 2011 New Revision: 171065 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171065 Log: PR c++/48132 * decl.c (check_array_designated_initializer): Allow integer index. (reshape_init_array_1): Set index on the elements. Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C Modified: branches/gcc-4_6-branch/gcc/cp/ChangeLog branches/gcc-4_6-branch/gcc/cp/decl.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Author: jason Date: Wed Mar 16 20:04:06 2011 New Revision: 171068 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171068 Log: PR c++/48132 * decl.c (check_array_designated_initializer): Allow integer index. (reshape_init_array_1): Set index on the elements. Added: trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed.