https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125412
Bug ID: 125412
Summary: [reflection] ICE in eval_type_trait, at
cp/reflect.cc:4136
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: c++26, ice-on-invalid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: alexey.saldyrkine at gmail dot com
Target Milestone: ---
ICE seems to occur when trying to extract a value from a failed variable
template. This happens when its auto type is deduced to void, or auto cannot be
deduced.
Godbolt: https://godbolt.org/z/7s59Ychjo
Code:
```
#include <meta>
namespace meta = std::meta;
void f(){};
auto g();
// ICE occurs in both cases
template<typename T>
auto var_template = f(); // auto is deduced to void
template<typename T>
auto var_template2 = g(); // auto cannot be deduced
consteval{
auto refl = meta::substitute(^^var_template,{^^int});
meta::extract<int>(refl);
auto refl2 = meta::substitute(^^var_template2,{^^int});
meta::extract<int>(refl2);
}
```
Error:
```
<source>:11:23: error: use of 'auto g()' before deduction of 'auto'
11 | auto var_template2 = g(); // auto cannot be deduced
| ~^~
<source>:11:23: error: use of 'auto g()' before deduction of 'auto'
<source>:18:1: in 'constexpr' expansion of '<lambda()> static()'
18 | }
| ^
<source>:9:6: error: variable or field 'var_template' declared void
9 | auto var_template = f(); // auto is deduced to void
| ^~~~~~~~~~~~
<source>: In static member function '<lambda()> static':
<source>:15:23: internal compiler error: in eval_type_trait, at
cp/reflect.cc:4136
15 | meta::extract<int>(refl);
| ~~~~~~~~~~~~~~~~~~^~~~~~
0x29e0948 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x29d558b internal_error(char const*, ...)
???:0
0xb2fce6 fancy_abort(char const*, int, char const*)
???:0
0xe0c203 process_metafunction(constexpr_ctx const*, tree_node*, tree_node*,
bool*, bool*, tree_node**)
???:0
0xb9d80c cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xb9ce4a cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xb9da3d cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xb9d586 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xb9e1a3 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xb9d290 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xb9d290 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xb9d80c cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xb9d0ff cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
???:0
0xbaf833 cxx_constant_value(tree_node*, tree_node*, int)
???:0
0xe2df4e finish_static_assert(tree_node*, tree_node*, unsigned long, bool,
bool, bool)
???:0
0xd82c33 c_parse_file()
???:0
0xf11b49 c_common_parse_file()
???:0
/cefs/4b/4bdd490966151a01e702d12b_gcc-trunk-20260521/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/4b/4bdd490966151a01e702d12b_gcc-trunk-20260521/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -mtune=generic -march=x86-64 -g -O0 -std=c++26 -fdiagnostics-color=always
-fno-verbose-asm -freflection -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
```