The following valid code snippet triggers an ICE since at least GCC 2.95.3: ================================= template<int> struct A { template<int> struct B { template<int> void foo() { struct C { C() {} }; } }; }; ================================= bug.cc: In member function 'void A<<anonymous> >::B<<anonymous> >::foo()': bug.cc:7: internal compiler error: tree check: expected class 'type', have 'declaration' (function_decl) in push_template_decl_real, at cp/pt.c:3857 Please submit a full bug report, [etc.]
Confirmed, though this appears to work up to and including the 4.1.2 release at least, in contrast to your assertion... W.
Well, it crashes for me: GCC 2.95.3: PR31516.cc: In method `A<{anon}>::B<{anon}>::foo()::C::C()': PR31516.cc:7: ../../../gcc-2.95.3/gcc/cp/pt.c:2493: Expect 't', have 'function_decl' GCC 3.0.4: PR31516.cc: In member function `void A<<anonymous> >::B<<anonymous> >::foo()': PR31516.cc:7: Tree check: expected class 't', have 'd' (function_decl) in push_template_decl_real, at cp/pt.c:2687 Please submit a full bug report, [etc.] GCC 3.2.3: PR31516.cc: In member function `void A<<anonymous> >::B<<anonymous> >::foo()': PR31516.cc:7: tree check: expected class 't', have 'd' (function_decl) in push_template_decl_real, at cp/pt.c:2776 Please submit a full bug report, [etc.] GCC 3.3.6: PR31516.cc: In member function `void A<<anonymous> >::B<<anonymous> >::foo()': PR31516.cc:7: internal compiler error: tree check: expected class 't', have 'd' (function_decl) in push_template_decl_real, at cp/pt.c:2897 Please submit a full bug report, [etc.] Maybe you don't have checking enabled for the release versions?
(In reply to comment #2) > Maybe you don't have checking enabled for the release versions? That appears to be the case (I thought I had set --enable-checking). In any case, I see the ICE on the currently maintained release branches, which is what counts anyway :-) W.
This is a duplicate of 33035 and indeed the latter isn't a regression, I'm fixing that. *** This bug has been marked as a duplicate of 33035 ***