------- testcase.C -------- template < int N > struct X { static const int value = X < N - 1 >::value; }; template struct X <1000>; --------------------------- (g++.dg/template/recurse2.C) Compiler output: $ gcc -gstabs -g testcase.C testcase.C:1:27: error: template instantiation depth exceeds maximum of 1024 (use -ftemplate-depth= to increase the maximum) instantiating 'X<-0x00000000000000017>::value' testcase.C:2:41: recursively instantiated from 'const int X<999>::value' testcase.C:2:41: instantiated from 'const int X<1000>::value' testcase.C:4:17: instantiated from here testcase.C:2:41: error: template instantiation depth exceeds maximum of 1024 (use -ftemplate-depth= to increase the maximum) instantiating 'struct X<-0x00000000000000019>' testcase.C:2:41: recursively instantiated from 'const int X<999>::value' testcase.C:2:41: instantiated from 'const int X<1000>::value' testcase.C:4:17: instantiated from here testcase.C:2:41: error: incomplete type 'X<-0x00000000000000019>' used in nested name specifier ==3448== Invalid read of size 4 ==3448== at 0x518875: pop_tinst_level (pt.c:7513) ==3448== by 0x54EAF2: instantiate_decl (pt.c:17402) ==3448== by 0x550681: do_type_instantiation (pt.c:16682) ==3448== by 0x5BAB68: cp_parser_explicit_instantiation (parser.c:12269) ==3448== by 0x5BDD89: cp_parser_declaration (parser.c:9415) ==3448== by 0x5BC569: cp_parser_declaration_seq_opt (parser.c:9328) ==3448== by 0x5BE234: c_parse_file (parser.c:3445) ==3448== by 0x6922F4: c_common_parse_file (c-opts.c:1070) ==3448== by 0x9F7423: toplev_main (toplev.c:870) ==3448== by 0x6376BBC: (below main) (in /lib64/libc-2.11.2.so) ==3448== Address 0x10 is not stack'd, malloc'd or (recently) free'd ==3448== testcase.C:4:17: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. Tested revisions: r166936 - crash 4.5 r166509 - crash 4.4 r166509 - OK
GCC 4.5.2 is being released, adjusting target milestone.
I can't reproduce this on head of 4.5 or 4.6.