Bug 49156 - [C++0x] Error reporting routines re-entered
Summary: [C++0x] Error reporting routines re-entered
Status: RESOLVED DUPLICATE of bug 44994
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2011-05-25 08:57 UTC by Jonathan Wakely
Modified: 2011-05-26 03:06 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2011-05-25 08:57:37 UTC
from a comment on PR 47336


template<typename T> T declval();

template<typename T>
struct S {

  template<typename U>
    static U get(const volatile T&);

  template<typename U>
    static decltype(*declval<U>()) get(...);

  typedef decltype(get<T>(declval<T>())) type;
};

struct X { };

S<X>::type x;



err.cc: In instantiation of ‘S<X>’:
err.cc:17:5:   instantiated from here
err.cc:12:42: error: no matching function for call to ‘S<X>::get(X)’
err.cc:12:42: note: candidates are:
err.cc:7:35: note: template<class U> static U S::get(const volatile T&) [with U = U, T = X]

Internal compiler error: Error reporting routines re-entered.
Comment 1 froydnj@codesourcery.com 2011-05-25 19:36:46 UTC
On 05/25/2011 05:14 AM, redi at gcc dot gnu.org wrote:
> template<typename T> T declval();
> 
> template<typename T>
> struct S {
> 
>   template<typename U>
>     static U get(const volatile T&);
> 
>   template<typename U>
>     static decltype(*declval<U>()) get(...);
> 
>   typedef decltype(get<T>(declval<T>())) type;
> };
> 
> struct X { };
> 
> S<X>::type x;
> 
> err.cc: In instantiation of ‘S<X>’:
> err.cc:17:5:   instantiated from here
> err.cc:12:42: error: no matching function for call to ‘S<X>::get(X)’
> err.cc:12:42: note: candidates are:
> err.cc:7:35: note: template<class U> static U S::get(const volatile T&) [with U
> = U, T = X]
> 
> Internal compiler error: Error reporting routines re-entered.

The backtrace for this is just lovely:

#2  0x00000000038bc424 in error_recursion (context=0x4f4fc00) at
/home/froydnj/src/combined-tree/gcc/diagnostic.c:879
#3  0x00000000038baece in diagnostic_report_diagnostic (context=0x4f4fc00,
diagnostic=0x7fffffff5120) at /home/froydnj/src/combined-tree/gcc/diagnostic.c:432
#4  0x00000000038bb67e in emit_diagnostic (kind=DK_ERROR, location=1524,
opt=0, gmsgid=0x395a198 "invalid use of template type parameter %qT") at
/home/froydnj/src/combined-tree/gcc/diagnostic.c:628
#5  0x000000000065c30a in cxx_incomplete_type_diagnostic
(value=0x7ffff7ff81f8, type=0x7ffff777ad20, diag_kind=DK_ERROR) at
/home/froydnj/src/combined-tree/gcc/cp/typeck2.c:437
#6  0x00000000007fbe8b in complete_type_or_maybe_complain
(type=0x7ffff777ad20, value=0x7ffff7ff81f8, complain=3) at
/home/froydnj/src/combined-tree/gcc/cp/typeck.c:153
#7  0x00000000007fb7b5 in require_complete_type_sfinae (value=0x7ffff7ff81f8,
complain=3) at /home/froydnj/src/combined-tree/gcc/cp/typeck.c:90
#8  0x00000000007fb7e6 in require_complete_type (value=0x7ffff7ff81f8) at
/home/froydnj/src/combined-tree/gcc/cp/typeck.c:99
#9  0x00000000004e88f2 in build_cxx_call (fn=0x7ffff7ff81f8, nargs=0,
argarray=0x7fffffff54c0) at /home/froydnj/src/combined-tree/gcc/cp/call.c:6686
#10 0x00000000004e86ba in build_over_call (cand=0x4fe2ee0, flags=524291,
complain=0) at /home/froydnj/src/combined-tree/gcc/cp/call.c:6650
#11 0x00000000004d7d35 in build_new_function_call (fn=0x7ffff7ecbf30,
args=0x7fffffff6168, koenig_p=0 '\000', complain=0) at
/home/froydnj/src/combined-tree/gcc/cp/call.c:3789
#12 0x0000000000946bc1 in finish_call_expr (fn=0x7ffff7ecbf30,
args=0x7fffffff6168, disallow_virtual=0 '\000', koenig_p=0 '\000', complain=0)
at /home/froydnj/src/combined-tree/gcc/cp/semantics.c:2152
#13 0x000000000061148e in tsubst_copy_and_build (t=0x7ffff7ff80a8,
args=0x7ffff7ecbd80, complain=0, in_decl=0x0, function_p=0 '\000',
integral_constant_expression_p=0 '\000') at
/home/froydnj/src/combined-tree/gcc/cp/pt.c:13076
#14 0x000000000060d0ae in tsubst_copy_and_build (t=0x7ffff777b028,
args=0x7ffff7ecbd80, complain=0, in_decl=0x0, function_p=0 '\000',
integral_constant_expression_p=0 '\000') at
/home/froydnj/src/combined-tree/gcc/cp/pt.c:12597
#15 0x000000000060c7cf in tsubst_expr (t=0x7ffff777b028, args=0x7ffff7ecbd80,
complain=0, in_decl=0x0, integral_constant_expression_p=0 '\000') at
/home/froydnj/src/combined-tree/gcc/cp/pt.c:12477
#16 0x00000000005fa410 in tsubst (t=0x7ffff777a150, args=0x7ffff7ecbd80,
complain=0, in_decl=0x0) at /home/froydnj/src/combined-tree/gcc/cp/pt.c:11044
#17 0x000000000072893f in dump_template_bindings (parms=0x0,
args=0x7ffff7ecbd80, typenames=0x7ffff777bc80) at
/home/froydnj/src/combined-tree/gcc/cp/error.c:317
#18 0x00000000007337b4 in dump_function_decl (t=0x7ffff7779730, flags=388) at
/home/froydnj/src/combined-tree/gcc/cp/error.c:1384
#19 0x0000000000730d16 in dump_template_decl (t=0x7ffff777d0b8, flags=132) at
/home/froydnj/src/combined-tree/gcc/cp/error.c:1207
#20 0x000000000072f9c9 in dump_decl (t=0x7ffff777d0b8, flags=132) at
/home/froydnj/src/combined-tree/gcc/cp/error.c:1068
#21 0x000000000073dd19 in decl_to_string (decl=0x7ffff777d0b8, verbose=1) at
/home/froydnj/src/combined-tree/gcc/cp/error.c:2541
#22 0x0000000000740892 in cp_printer (pp=0x4f6b5a0, text=0x7fffffff98a0,
spec=0x4f503e1 "D", precision=0, wide=0 '\000', set_locus=0 '\000', verbose=1
'\001') at /home/froydnj/src/combined-tree/gcc/cp/error.c:3079
#23 0x00000000038be660 in pp_base_format (pp=0x4f6b5a0, text=0x7fffffff98a0)
at /home/froydnj/src/combined-tree/gcc/pretty-print.c:508
#24 0x00000000038bb26c in diagnostic_report_diagnostic (context=0x4f4fc00,
diagnostic=0x7fffffff98a0) at /home/froydnj/src/combined-tree/gcc/diagnostic.c:541
#25 0x00000000038bb777 in inform (location=1269, gmsgid=0x3948956 "%s%#D") at
/home/froydnj/src/combined-tree/gcc/diagnostic.c:641
#26 0x00000000004d4a50 in print_z_candidate (msgstr=0x0, candidate=0x4fe2e00)
at /home/froydnj/src/combined-tree/gcc/cp/call.c:3133
#27 0x00000000004d4d71 in print_z_candidates (loc=1524, candidates=0x4fe2e00)
at /home/froydnj/src/combined-tree/gcc/cp/call.c:3214

It looks like we're building a separate DECL to print it and we need a
complete type along the way, but creating the complete type causes problems
and we fall over.
Comment 2 Jason Merrill 2011-05-25 20:41:24 UTC
This turns out to be the same issue as 44994.

*** This bug has been marked as a duplicate of bug 44994 ***
Comment 3 Jason Merrill 2011-05-26 02:22:49 UTC
Author: jason
Date: Thu May 26 02:22:46 2011
New Revision: 174256

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174256
Log:
	PR c++/49156
	* error.c (dump_template_bindings): Set processing_template_decl
	for a partial instantiation.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/error4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/error.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Jason Merrill 2011-05-26 03:06:19 UTC
Author: jason
Date: Thu May 26 03:06:17 2011
New Revision: 174261

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174261
Log:
	PR c++/49156
	* error.c (dump_template_bindings): Set processing_template_decl
	for a partial instantiation.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/error4.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/error.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog