https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115318
Bug ID: 115318
Summary: decltype(lambda) with some templates causes ICE
Product: gcc
Version: 14.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
Target Milestone: ---
template<typename T> struct S {};
template<int i = 4>
void foo()
{
using foo_t = decltype([](){});
[]<int k = 6>() { S<foo_t>{}; }();
}
void bar() { foo(); }
-std=c++20
<source>: In instantiation of 'foo<>()::<lambda()> [with int k = 6]':
<source>:7:36: required from 'void foo() [with int i = 4]'
7 | []<int k = 6>() { S<foo_t>{}; }();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
<source>:10:17: required from here
10 | void bar() { foo(); }
| ~~~^~
<source>:6:28: internal compiler error: in tsubst, at cp/pt.cc:16401
6 | using foo_t = decltype([](){});
| ^~~~~~
0x202ef4c internal_error(char const*, ...)
???:0
0x778915 fancy_abort(char const*, int, char const*)
???:0
0x938dd0 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x943a11 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x939200 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x93c437 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0x931a0f instantiate_decl(tree_node*, bool, bool)
???:0
0x831fb7 maybe_instantiate_decl(tree_node*)
???:0
0x8332f7 mark_used(tree_node*, int)
???:0
0x7a20a3 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
???:0
0x9602fe finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0x931a0f instantiate_decl(tree_node*, bool, bool)
???:0
0x94d2e3 instantiate_pending_templates(int)
???:0
0x835608 c_parse_final_cleanups()
???:0
0xa0c508 c_common_parse_file()
???:0
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.
Compiler returned: 1
If you make the first lambda a template ( decltype([]<int>(){}) ), you'll get a
internal compiler error: Segmentation fault instead. Probably the same root
cause.
Online reproducer: https://godbolt.org/z/EfxPxKWhd
I tried searching for duplicates, but every open issue I could find in bug
#107430 is a mess, I can't determine if it's the same.