https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124689
Bug ID: 124689
Summary: ICE on code pretending to be <meta>
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ivan.lazaric.gcc at gmail dot com
Target Milestone: ---
```cpp
namespace std::meta {
using info = decltype(^^::);
// actual signature should be `size_t(info, unsigned)`
consteval unsigned extent(info, info);
}
consteval {
extent(^^int, ^^int);
}
```
Flags: "-std=c++26 -freflection"
This ICEs:
```
bar.cpp:10:1: in 'constexpr' expansion of '<lambda()> static()'
10 | }
| ^
bar.cpp:9:7: internal compiler error: in tree_to_uhwi, at tree.h:5127
9 | extent(^^int, ^^int);
| ~~~~~~^~~~~~~~~~~~~~
0x21f867b internal_error(char const*, ...)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/diagnostic-global-context.cc:787
0x7af099 fancy_abort(char const*, int, char const*)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/diagnostics/context.cc:1823
0x76b2cb tree_to_uhwi(tree_node const*)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/tree.h:5127
0x76b2cb eval_extent
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/reflect.cc:4723
0x76b2cb process_metafunction(constexpr_ctx const*, tree_node*, tree_node*,
bool*, bool*, tree_node**)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/reflect.cc:7906
0x7fd9db cxx_eval_call_expression
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:4018
0x800ff3 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:9356
0x801874 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:10069
0x801af1 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:9573
0x8010d6 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:9625
0x8012f6 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:10345
0x7ff0a1 cxx_eval_call_expression
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:4517
0x800ff3 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:9356
0x801fbd cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:9866
0x80debe cxx_eval_outermost_constant_expr
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:10949
0x80f1c3 cxx_constant_value(tree_node*, tree_node*, int)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/constexpr.cc:11218
0x9f355e finish_static_assert(tree_node*, tree_node*, unsigned long, bool,
bool, bool)
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/semantics.cc:13107
0x956377 cp_parser_consteval_block
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/parser.cc:17770
0x97b5df cp_parser_declaration
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/parser.cc:17618
0x97dc22 cp_parser_toplevel_declaration
/home/ilazaric/repos/ALL/submodules/gcc/gcc/cp/parser.cc:17722
/opt/GCC/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/cc1plus -quiet -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE bar.cpp -quiet -dumpdir a- -dumpbase bar.cpp
-dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=c++26 -freflection
-fsyntax-only -o /dev/null
```
This feels like a rather odd bug report, most people wouldn't do
such weird stuff. As I wasn't sure I chose to report it.
Maybe such tricks could be an attack vector for malicious actors,
against some compilation services. Don't know, not an expert.