https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123451
Bug ID: 123451
Summary: ICE: error reporting routines re-entered when
diagnosing conversion failure involving C++23 auto(x)
in decltype
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: 522024330006 at smail dot nju.edu.cn
Target Milestone: ---
To reproduce: https://godbolt.org/z/cobqbWedT
GCC crashes when a template function uses the C++23 auto(x) syntax inside a
decltype specifier and is subsequently called with an incompatible argument
type. The crash is caused by "error reporting routines re-entered," indicating
a recursive failure during the diagnostic phase.
Program:
```c
template<typename T>
void func(decltype(auto(T()))) {}
int main() {
// crash here
func<int>([](){});
}
```
Part of the traceback:
```
internal compiler error: error reporting routines re-entered.
0x5da03aa pedwarn(unsigned long, diagnostic_option_id, char const*, ...)
/workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:291
0x16f8612 build_functional_cast_1
/workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:2512
0x16f8eee build_functional_cast(unsigned long, tree_node*, tree_node*, int)
/workspace/install/gcc/src/gcc/gcc/cp/typeck2.cc:2613
0x1523522 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
/workspace/install/gcc/src/gcc/gcc/cp/pt.cc:20788
0x1500309 tsubst(tree_node*, tree_node*, int, tree_node*)
/workspace/install/gcc/src/gcc/gcc/cp/pt.cc:17250
0x115e4e0 dump_template_bindings
/workspace/install/gcc/src/gcc/gcc/cp/error.cc:597
0x116a318 dump_substitution
/workspace/install/gcc/src/gcc/gcc/cp/error.cc:1811
0x116d7b2 dump_function_decl
/workspace/install/gcc/src/gcc/gcc/cp/error.cc:1983
0x1168038 dump_decl
/workspace/install/gcc/src/gcc/gcc/cp/error.cc:1537
0x117adde decl_to_string
/workspace/install/gcc/src/gcc/gcc/cp/error.cc:3457
0x1182521 cp_printer
/workspace/install/gcc/src/gcc/gcc/cp/error.cc:4721
0x5df8091 format_phase_2
/workspace/install/gcc/src/gcc/gcc/pretty-print.cc:2158
0x5df4514 pretty_printer::format(text_info&)
/workspace/install/gcc/src/gcc/gcc/pretty-print.cc:1711
0x18ac446 pp_format(pretty_printer*, text_info*)
/workspace/install/gcc/src/gcc/gcc/pretty-print.h:594
0x5d3e8a4 diagnostic_context::report_diagnostic(diagnostic_info*)
/workspace/install/gcc/src/gcc/gcc/diagnostic.cc:1505
0x5d3f2b7 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
/workspace/install/gcc/src/gcc/gcc/diagnostic.cc:1641
0x5d9f5ae inform(rich_location*, char const*, ...)
/workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:136
0xea9e04 maybe_inform_about_fndecl_for_bogus_argument_init(tree_node*, int,
char const*)
/workspace/install/gcc/src/gcc/gcc/cp/call.cc:8567
0xeab9a5 convert_like_internal
/workspace/install/gcc/src/gcc/gcc/cp/call.cc:8767
0xeb0f15 convert_like
/workspace/install/gcc/src/gcc/gcc/cp/call.cc:9416
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```