https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125268
Bug ID: 125268
Summary: ICE: using return type of lambda with deduced NTTP
pack as a templated type alias
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: email at miropalmu dot cc
Target Milestone: ---
Following code results in a ICE with latest GCC while Clang and MSVC accept it
(https://godbolt.org/z/TYoW44b6r):
```
template <auto... S>
struct sequence{ };
template <typename>
using should_be_int = decltype(
[]<auto... S>(sequence<S...>) {
return 42;
}(sequence<>()));
template <should_be_int<float>>
void foo(){}
template <typename T, should_be_int<T>>
void bar(){}
int main() {
foo<1>(); // ok
bar<float, 1>(); //not ok
}
```
Error message:
```
<source>: In substitution of 'template<auto ...S> <lambda(sequence<S ...>)>
[with auto ...S = {}]':
<source>:6:5: required from here
6 | []<auto... S>(sequence<S...>) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 | return 42;
| ~~~~~~~~~~
8 | }(sequence<>()));
| ~
<source>:6:5: internal compiler error: in tsubst_pack_expansion, at
cp/pt.cc:14346
6 | []<auto... S>(sequence<S...>) {
| ^
0x29c10d8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x29b5d1b internal_error(char const*, ...)
???:0
0xb2e550 fancy_abort(char const*, int, char const*)
???:0
0xdc7339 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xdca954 tsubst_argument_pack(tree_node*, tree_node*, int, tree_node*)
???:0
0xdc72d4 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
???:0
0xdba02d tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xdba186 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xdd702d instantiate_template(tree_node*, tree_node*, int)
???:0
0xde866a fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0xb6b4c2 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
???:0
0xe22d26 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xdb9d66 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0xdcc643 coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
???:0
0xde7e83 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0xb6706f build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
???:0
0xe22715 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xd81203 c_parse_file()
???:0
0xf0fbb9 c_common_parse_file()
???:0
/cefs/6b/6ba0b41af24908467c2fddc0_gcc-trunk-20260511/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/6b/6ba0b41af24908467c2fddc0_gcc-trunk-20260511/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -Wall -Wpedantic -Wextra
-Werror -std=c++23 -fdiagnostics-color=always -fno-verbose-asm -o /app/output.s
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
```