http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50015
Summary: std::initializer_list<std::string> members are not properly initialized Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: danny....@tu-dortmund.de Created attachment 24940 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24940 Output of 'g++ -std=c++0x -save-temps -o test-case test-case.cc' When creating a std::initializer_list<std::string> as part of a struct, the actual object is not properly initialized. Consider the following test case: -- BEGIN -- #include <initializer_list> #include <iostream> #include <string> struct T { std::initializer_list<std::string> s; }; T foo { {"foo", "bar", "baz"} }; int main(int, char**) { for (auto t = foo.s.begin(), t_end = foo.s.end() ; t != t_end ; ++t) std::cout << *t << std::endl; return 0; } -- END -- After compiling this test case using g++ -Wall -pedantic -std=c++0x -o test-case test-case.cc [no errors, no warnings] the execution of the resulting binary via ./test-case either raises a segmentation fault or produces garbled output, e.g., foo1`particularÿÿÿÿbar1ÿÿ Looks very much like terminating '\0's are not in place. This bug was first seen when using gcc-4.4.5 and is reproducable under gcc-4.5.0 up to gcc-4.6.1. The particular version of gcc-4.6.1 was configured as configure \ --prefix=/het/packages/gcc-${VERSION} \ --program-prefix=het- \ --program-suffix=-${VERSION} \ --enable-languages=c,c++ \ --disable-multilib and built on an amd64 system. I will attach the output of g++ -std=c++0x -save-temps -o test-case test-case.cc g++ -std=c++0x -fdump-tree-gimple -o test-case test-case.cc to this bug report. Thank you to Alexander Faeroey for help in reducing the segfaulting code to a manageable test case.