--- begin test.cc ---- template <typename T, short s> class S { public: static const T m_value; };
template <typename T, short s> const int S<int, 0>::m_value = 1; int main(int argc, char *argv[]) { int i = S<int, 0>::m_value; return 0; } --- end test.cc --- g++ test.cc test.cc: In function 'int main(int, char**)': test.cc:9: instantiated from 'const int S<int, 0>::m_value' test.cc:9: instantiated from here test.cc:9: internal compiler error: in instantiate_decl, at cp/pt.c:11621 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. Same with gcc version 4.1.2 20061208 and 4.2.0 20061212 Example compiles without error when patched like this: -template <typename T, short s> const int S<int, 0>::m_value = 1; +template <> const int S<int, 0>::m_value = 1; -- Summary: ICE in instantiate_decl, at cp/pt.c:11621 on invalid template code Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ps dot report at gmx dot net GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30234