This code doesn't compile on both GCC 3.4.3 and GCC 4.1.0 (20050320). -------------- begin .ii file
# 1 "bug_gcc.cc" # 1 "<built-in>" # 1 "<command line>" # 1 "bug_gcc.cc" template <int N, typename Tail_> struct List { static const int Value = N; typedef Tail_ Tail; }; struct NullList; template < bool B, int T, int F > struct If_ { static const int res = T; }; template < int T, int F > struct If_< false, T, F > { static const int res = F; }; template < class List > struct GreatestSub { private: static const int N = List::Value; static const int current = (If_<(N > 0), (N), (0)>::ret); static const bool is_max = (current > 0); static const int max_value = (If_<(is_max), (0), (0)>::ret); }; template <> struct GreatestSub<NullList> {}; int main() { GreatestSub< List<50, NullList> >::current; } -------------- end .ii file -------------- begin version infos sh-3.00$ g++ bug_gcc.cc -W -Wall bug_gcc.cc: In instantiation of `GreatestSub<List<50, NullList> >': bug_gcc.cc:36: instantiated from here bug_gcc.cc:25: error: `ret' is not a member of `If_< true, 50, 0>' g++: Internal error: Segmentation fault (program cc1plus) Please submit a full bug report. See <URL:http://bugs.gentoo.org/> for instructions. sh-3.00$ g++ --version g++ (GCC) 3.4.3-20050110 (Gentoo Linux 3.4.3.20050110-r2, ssp-3.4.3.20050110-0, pie-8.7.7) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. sh-3.00$ g++-snapshot bug_gcc.cc bug_gcc.cc: In instantiation of 'GreatestSub<List<50, NullList> >': bug_gcc.cc:36: instantiated from here bug_gcc.cc:25: error: 'ret' is not a member of 'If_<true, 50, 0>' g++-snapshot: Internal error: Segmentation fault (program cc1plus) Please submit a full bug report. See <URL:http://gcc.gnu.org/bugs.html> for instructions. sh-3.00$ g++-snapshot --version g++-snapshot (GCC) 4.1.0 20050320 (experimental) Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -------------- end version infos gentoo configuration of gcc package options: (-altivec) -bootstrap -boundschecking -build +fortran -gcj +gtk -hardened -ip28 (-multilib) -multislot (-n32) (-n64) +nls -nocxx -nopie -nossp -objc -static -- Summary: Segv on undefined static member of a template class. Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: micha at lrde dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: Linux mahaena 2.6.11-gentoo-r6 #2 SMP Sat Apr 30 02:17:43 CEST 2 GCC host triplet: Linux mahaena 2.6.11-gentoo-r6 #2 SMP Sat Apr 30 02:17:43 CEST 2 GCC target triplet: Linux mahaena 2.6.11-gentoo-r6 #2 SMP Sat Apr 30 02:17:43 CEST 2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22181