This C++ code gets an ICE with gcc 4.2 and with mainline. I believe this is valid C++ code.
namespace { template <typename T> class A { virtual T f1() { return c; } static const T c = 0; }; A<int> v; } foo.cc: In instantiation of const int <unnamed>::A<int>::c: foo.cc:7: instantiated from T<unnamed>::A<T>::f1() [with T = int] foo.cc:11: instantiated from here foo.cc:8: internal compiler error: in make_rtl_for_nonlocal_decl, at cp/decl.c:4967 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. -- Summary: ICE on valid C++ virtual template static member in namespace Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ian at airs dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33094