The following invalid code snippet causes an ICE since GCC 4.1.0: ================================= union A { char c; };
template<int> void foo() { (A) { 0, 0 }; } void bar() { foo<0>(); } ================================= bug.cc: In function 'void foo() [with int <anonymous> = 0]': bug.cc:10: instantiated from here bug.cc:5: internal compiler error: in process_init_constructor_union, at cp/typeck2.c:972 Please submit a full bug report, [etc.] If I replace "union" by "struct" the code compiles without error-message or warning. Without the template the code triggers an error message in both cases: bug.cc: In function 'void foo()': bug.cc:5: error: too many initializers for 'A' Before GCC 4.1.0 the code triggered a pedwarn (and compiled without problems with -fpermissive). -- Summary: [4.1/4.2 regression] Trouble with invalid initializers Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: ice-on-invalid-code, accepts-invalid, monitored Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: reichelt at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28248