[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-18 Thread jason at gcc dot gnu dot org


--- Comment #20 from jason at gcc dot gnu dot org  2010-04-18 14:42 ---
(In reply to comment #19)
 Well, the patch is mostly done, it reduces the output from 11 to 1 lines and 
 it
 neatly points out where is the recursive instantiation. So I hope you may
 reconsider, unless you think the 101 lines are useful to the user somehow.

101 lines? Is that a typo?

If this change only applies to the case where all 11 lines would be
instantiations of the same template I guess it sounds reasonable, though the
11-line output seems a bit clearer as to where the recursion is happening. 
Perhaps two instantiation lines in this case so we see the first recursion?


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-18 Thread manu at gcc dot gnu dot org


--- Comment #21 from manu at gcc dot gnu dot org  2010-04-18 16:16 ---
(In reply to comment #20)
 (In reply to comment #19)
  Well, the patch is mostly done, it reduces the output from 11 to 1 lines 
  and it
  neatly points out where is the recursive instantiation. So I hope you may
  reconsider, unless you think the 101 lines are useful to the user somehow.
 
 101 lines? Is that a typo?

Yes, sorry. I meant 11 lines.

 If this change only applies to the case where all 11 lines would be
 instantiations of the same template I guess it sounds reasonable, though the
 11-line output seems a bit clearer as to where the recursion is happening. 
 Perhaps two instantiation lines in this case so we see the first recursion?

My current patch prints:

/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-0x00018'
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from 'const int
X1000::value'
/home/manuel/src/pr9335.C:4:17:   instantiated from here

Is that ok or you would prefer the following?

/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-0x00018'
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from 'const int
XN-1::value'
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from 'const int
X1000::value'
/home/manuel/src/pr9335.C:4:17:   instantiated from here

I think with some tinkering I can reach that output but I don't see which
useful information provides, since the location of the extra line is the same
as the error line and the recursive instantiation line.


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-18 Thread jason at gcc dot gnu dot org


--- Comment #22 from jason at gcc dot gnu dot org  2010-04-18 17:09 ---
(In reply to comment #21)
 Is that ok or you would prefer the following?
 
 /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-0x00018'
 /home/manuel/src/pr9335.C:2:36:   recursively instantiated from 'const int
 XN-1::value'
 /home/manuel/src/pr9335.C:2:36:   recursively instantiated from 'const int
 X1000::value'
 /home/manuel/src/pr9335.C:4:17:   instantiated from here

I was thinking just

/home/manuel/src/pr9335.C:2:36:   recursively instantiated from 'const int
X999::value'
/home/manuel/src/pr9335.C:2:36:   instantiated from 'const int X1000::value'

I think seeing one iteration would make it clearer.


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-18 Thread manu at gcc dot gnu dot org


--- Comment #23 from manu at gcc dot gnu dot org  2010-04-18 17:40 ---
Oh, that is not very difficult to do. But notice that you will still get the
last line:

/home/manuel/src/pr9335.C:4:17:   instantiated from here

so we go from 11 to 3 lines. I think that is ok.

So go ahead, commit your patch and I will update mine to produce that.


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-17 Thread manu at gcc dot gnu dot org


--- Comment #19 from manu at gcc dot gnu dot org  2010-04-17 07:59 ---
(In reply to comment #18)
 The output with my patch is
 
 wa.C:2:38: error: template instantiation depth exceeds maximum of 1024 (use
 -ftemplate-depth= to increase the maximum) instantiating �struct
 X-0x00018�
 wa.C:2:38:   instantiated from �const int X-0x00017::value�
 wa.C:2:38:   instantiated from �const int X-0x00016::value�
 wa.C:2:38:   instantiated from �const int X-0x00015::value�
 wa.C:2:38:   instantiated from �const int X-0x00014::value�
 wa.C:2:38:   instantiated from �const int X-0x00013::value�
 wa.C:2:38:   [ skipping 1014 instantiation contexts ]
 wa.C:2:38:   instantiated from �const int X996::value�
 wa.C:2:38:   instantiated from �const int X997::value�
 wa.C:2:38:   instantiated from �const int X998::value�
 wa.C:2:38:   instantiated from �const int X999::value�
 wa.C:2:38:   instantiated from �const int X1000::value�
 wa.C:4:17:   instantiated from here
 
 wa.C:2:38: error: incomplete type �X-0x00018� used in nested name
 specifier
 
 it avoids the error cascade by avoiding all the non-constant initializer
 errors.
 
 I guess your patch just cuts down the instantiated from list to one 
 element? 

No, to 2 elements, the original instantiation, and the recursive instantiation.

/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-0x00018�
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from �const int
X1000::value�
/home/manuel/src/pr9335.C:4:17:   instantiated from here

 I think the previous change to skip all but 10 is good enough.

Well, the patch is mostly done, it reduces the output from 11 to 1 lines and it
neatly points out where is the recursive instantiation. So I hope you may
reconsider, unless you think the 101 lines are useful to the user somehow.


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-16 Thread jason at gcc dot gnu dot org


--- Comment #16 from jason at gcc dot gnu dot org  2010-04-16 22:07 ---
Created an attachment (id=20403)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20403action=view)
patch to stop error cascade

This patch fixes the repeated error; it turns out I was wrong about this being
related to default int.  Do you want to experiment more with this patch or
should I just check it in?


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-16 Thread manu at gcc dot gnu dot org


--- Comment #17 from manu at gcc dot gnu dot org  2010-04-16 22:24 ---
(In reply to comment #16)
 Created an attachment (id=20403)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20403action=view) [edit]
 patch to stop error cascade
 
 This patch fixes the repeated error; it turns out I was wrong about this being
 related to default int.  Do you want to experiment more with this patch or
 should I just check it in?
 

I still don't understand why this fixes the problem, but whatever. What is the
output with your patch?

Do you think that my patch is to emit recursively instantiated would still be
useful in general? Should I submit it properly?


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-16 Thread jason at gcc dot gnu dot org


--- Comment #18 from jason at gcc dot gnu dot org  2010-04-17 03:53 ---
The output with my patch is

wa.C:2:38: error: template instantiation depth exceeds maximum of 1024 (use
-ftemplate-depth= to increase the maximum) instantiating ‘struct
X-0x00018’
wa.C:2:38:   instantiated from ‘const int X-0x00017::value’
wa.C:2:38:   instantiated from ‘const int X-0x00016::value’
wa.C:2:38:   instantiated from ‘const int X-0x00015::value’
wa.C:2:38:   instantiated from ‘const int X-0x00014::value’
wa.C:2:38:   instantiated from ‘const int X-0x00013::value’
wa.C:2:38:   [ skipping 1014 instantiation contexts ]
wa.C:2:38:   instantiated from ‘const int X996::value’
wa.C:2:38:   instantiated from ‘const int X997::value’
wa.C:2:38:   instantiated from ‘const int X998::value’
wa.C:2:38:   instantiated from ‘const int X999::value’
wa.C:2:38:   instantiated from ‘const int X1000::value’
wa.C:4:17:   instantiated from here

wa.C:2:38: error: incomplete type ‘X-0x00018’ used in nested name
specifier

it avoids the error cascade by avoiding all the non-constant initializer
errors.

I guess your patch just cuts down the instantiated from list to one element? 
I think the previous change to skip all but 10 is good enough.


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-14 Thread lopezibanez at gmail dot com


--- Comment #15 from lopezibanez at gmail dot com  2010-04-14 10:09 ---
Subject: Re:  repeated diagnostic when maximum template depth is 
exceeded

When that happens? I am sorry but your answer does not help me to find
how to fix this.


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-13 Thread manu at gcc dot gnu dot org


--- 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-0x00018’
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from ‘const int
X1000::value’
/home/manuel/src/pr9335.C:4:17:   instantiated from here

/home/manuel/src/pr9335.C:2:36: error: incomplete type
‘X-0x00018’ used in nested name specifier
/home/manuel/src/pr9335.C: In instantiation of ‘const int
X-0x00016::value’:
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from ‘const int
X1000::value’
/home/manuel/src/pr9335.C:4:17:   instantiated from here
/home/manuel/src/pr9335.C:2:36: error: ‘X-0x00016::value’ cannot
be initialized by a non-constant expression when being declared
/home/manuel/src/pr9335.C: In instantiation of ‘const int
X-0x00015::value’:
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from ‘const int
X1000::value’
/home/manuel/src/pr9335.C:4:17:   instantiated from here
/home/manuel/src/pr9335.C:2:36: error: ‘X-0x00015::value’ cannot
be initialized by a non-constant expression when being declared
/home/manuel/src/pr9335.C: In instantiation of ‘const int
X-0x00014::value’:
/home/manuel/src/pr9335.C:2:36:   recursively instantiated from ‘const int
X1000::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 0x7717bf00 value
type integer_type 0x77490f18 int readonly type_6 SI
size integer_cst 0x7754d960 constant 32
unit size integer_cst 0x7754d668 constant 4
align 32 symtab 0 alias set -1 canonical type 0x77490f18 precision
32 min integer_cst 0x7754d8e8 -2147483648 max integer_cst 0x7754d910
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
0x775\
4d960 32 unit size integer_cst 0x7754d668 4
align 32 context record_type 0x7717ddc8 X initial error_mark
0x77555ca8
template-info 0x77177600 chain type_decl 0x7717e8a0 X

Couldn't we abort all this earlier?


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-04-13 Thread jason at gcc dot gnu dot org


--- Comment #14 from jason at gcc dot gnu dot org  2010-04-14 01:41 ---
That sounds like another case where trying to recover from an error by changing
a problematic type to 'int' doesn't actually improve matters.


-- 


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



[Bug c++/9335] repeated diagnostic when maximum template depth is exceeded

2010-02-19 Thread manu at gcc dot gnu dot org


--- Comment #12 from manu at gcc dot gnu dot org  2010-02-20 01:55 ---
The reason why this testcase cannot be solved like bug 23510 is that this
testcase produces many repeated:

 error: template instantiation depth exceeds maximum of 500 (use
   -ftemplate-depth-NN to increase the maximum) instantiating `struct X500'

each of them with their own long list of instantiations. In fact, this could
have been detected in the testsuite:

gcc/testsuite/g++.dg/template/recurse.C

but the testsuite does not detect repeated messages. We should give just one
error like Comeau does. This is a regression but I don't know in which version
this used to work.


-- 

manu at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|manu at gcc dot gnu dot org |unassigned at gcc dot gnu
   ||dot org
 Status|ASSIGNED|NEW
Summary|Inordinately long output|repeated diagnostic when
   |when maximum template depth |maximum template depth is
   |is exceeded |exceeded


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