https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126011
Bug ID: 126011
Summary: ICE on template that references member of struct
defined in expansion statement
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: keipitalists at proton dot me
Target Milestone: ---
https://godbolt.org/z/5KGv7s7cq
```
template <typename Type>
constexpr auto specced = &Type::Get;
int main() {
template for (constexpr auto v : {1,2,3})
{
struct MyType
{
constexpr void Get() { }
};
specced<MyType>;
}
}
```
```
<source>: In instantiation of 'constexpr void main()::MyType::Get()':
<source>:3:26: required from 'constexpr const auto specced<main()::MyType>'
3 | constexpr auto specced = &Type::Get;
| ^~~~~~~~~~
<source>:12:9: required from here
12 | specced<MyType>;
| ^~~~~~~~~~~~~~~
<source>:3:26: internal compiler error: in instantiate_decl, at cp/pt.cc:28838
3 | constexpr auto specced = &Type::Get;
| ^~~~~~~~~~
0x226a6a8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x226399b internal_error(char const*, ...)
???:0
0x7f8eda fancy_abort(char const*, int, char const*)
???:0
0x8c8af8 mark_used(tree_node*, int)
???:0
0xa6eeca build_x_unary_op(unsigned long, tree_code, cp_expr, tree_node*, int)
???:0
0xa03557 instantiate_decl(tree_node*, bool, bool)
???:0
0x8c7761 maybe_instantiate_decl(tree_node*)
???:0
0x8c8d97 mark_used(tree_node*, int)
???:0
0xa38ac4 finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*,
bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned long)
???:0
0x9c751d c_parse_file()
???:0
0xaf3a69 c_common_parse_file()
???:0
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/bin/../libexec/gcc/x86_64-linux-gnu/16.1.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_x86_gcc_16.1.0/bin/../lib/gcc/x86_64-linux-gnu/16.1.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -std=c++26
-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
```