------- Comment #13 from manu at gcc dot gnu dot org  2010-04-13 23:48 -------
I have a patch that prints this:

/home/manuel/src/pr9335.C:2:36: error: template instantiation depth exceeds
maximum of 1024 (use -ftemplate-depth= to increase the maximum) instantiating
‘struct X<-0x00000000000000018>’
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from ‘const int
X<1000>::value’
/home/manuel/src/pr9335.C:4:17:   instantiated from here

/home/manuel/src/pr9335.C:2:36: error: incomplete type
‘X<-0x00000000000000018>’ used in nested name specifier
/home/manuel/src/pr9335.C: In instantiation of ‘const int
X<-0x00000000000000016>::value’:
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from ‘const int
X<1000>::value’
/home/manuel/src/pr9335.C:4:17:   instantiated from here
/home/manuel/src/pr9335.C:2:36: error: ‘X<-0x00000000000000016>::value’ cannot
be initialized by a non-constant expression when being declared
/home/manuel/src/pr9335.C: In instantiation of ‘const int
X<-0x00000000000000015>::value’:
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from ‘const int
X<1000>::value’
/home/manuel/src/pr9335.C:4:17:   instantiated from here
/home/manuel/src/pr9335.C:2:36: error: ‘X<-0x00000000000000015>::value’ cannot
be initialized by a non-constant expression when being declared
/home/manuel/src/pr9335.C: In instantiation of ‘const int
X<-0x00000000000000014>::value’:
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from ‘const int
X<1000>::value’
/home/manuel/src/pr9335.C:4:17:   instantiated from here

then continues for 4000 lines

It is perhaps an improvement but not a fix.

@Jason,

I see that in pt.c (instantiate_decl), after we get the first error, then init
== error_mark_node. However, the parser continues building the declaration as
if nothing. And we end up with something like:

 <var_decl 0x7ffff717bf00 value
    type <integer_type 0x7ffff7490f18 int readonly type_6 SI
        size <integer_cst 0x7ffff754d960 constant 32>
        unit size <integer_cst 0x7ffff754d668 constant 4>
        align 32 symtab 0 alias set -1 canonical type 0x7ffff7490f18 precision
32 min <integer_cst 0x7ffff754d8e8 -2147483648> max <integer_cst 0x7ffff754d910
2147483647\
>>
    readonly constant used public static tree_1 tree_2 tree_3 external nonlocal
decl_3 decl_6 SI file /home/manuel/src/pr9335.C line 2 col 36 size <integer_cst
0x7ffff75\
4d960 32> unit size <integer_cst 0x7ffff754d668 4>
    align 32 context <record_type 0x7ffff717ddc8 X> initial <error_mark
0x7ffff7555ca8>
    template-info 0x7ffff7177600 chain <type_decl 0x7ffff717e8a0 X>>

Couldn't we abort all this earlier?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9335

Reply via email to