https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119045
Bug ID: 119045
Summary: ICE when using _Complex accessors, in
cxx_eval_store_expression, at cp/constexpr.cc:6418
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dangelog at gmail dot com
Target Milestone: ---
Hello,
The following reduced testcase: https://gcc.godbolt.org/z/1n1sdYvqe
constexpr bool test()
{
__complex__ float f{1, 2};
float &r = __real__ f;
r = 42;
return true;
}
static_assert(test());
causes an ICE on GCC trunk:
// test3.cc:9:19: in ‘constexpr’ expansion of ‘test()’
// test3.cc:5:7: internal compiler error: in cxx_eval_store_expression, at
cp/constexpr.cc:6418
// 5 | r = 42;
// | ~~^~~~
// 0x28aab0f internal_error(char const*, ...)
// ../../gcc.git/gcc/diagnostic-global-context.cc:517
// 0xabc087 fancy_abort(char const*, int, char const*)
// ../../gcc.git/gcc/diagnostic.cc:1722
// 0x7c94b5 cxx_eval_store_expression
// ../../gcc.git/gcc/cp/constexpr.cc:6418
// 0xb1636f cxx_eval_constant_expression
// ../../gcc.git/gcc/cp/constexpr.cc:7962
// 0xb165ad cxx_eval_constant_expression
// ../../gcc.git/gcc/cp/constexpr.cc:8369
// 0xb164e1 cxx_eval_constant_expression
// ../../gcc.git/gcc/cp/constexpr.cc:8020
// 0xb16ace cxx_eval_constant_expression
// ../../gcc.git/gcc/cp/constexpr.cc:8036
// 0xb176d7 cxx_eval_statement_list
// ../../gcc.git/gcc/cp/constexpr.cc:7119
// 0xb176d7 cxx_eval_constant_expression
// ../../gcc.git/gcc/cp/constexpr.cc:8615
// 0xb16cd7 cxx_eval_constant_expression
// ../../gcc.git/gcc/cp/constexpr.cc:8624
// 0xb14c57 cxx_eval_call_expression
// ../../gcc.git/gcc/cp/constexpr.cc:3312
// 0xb1696e cxx_eval_constant_expression
// ../../gcc.git/gcc/cp/constexpr.cc:7809
// 0xb236c2 cxx_eval_outermost_constant_expr
// ../../gcc.git/gcc/cp/constexpr.cc:9104
// 0xb28ab3 maybe_constant_value(tree_node*, tree_node*, mce_value)
// ../../gcc.git/gcc/cp/constexpr.cc:9407
// 0xd53b00 finish_static_assert(tree_node*, tree_node*, unsigned long, bool,
bool)
// ../../gcc.git/gcc/cp/semantics.cc:12438
// 0xccc5e7 cp_parser_declaration
// ../../gcc.git/gcc/cp/parser.cc:16180
// 0xccda5b cp_parser_toplevel_declaration
// ../../gcc.git/gcc/cp/parser.cc:16201
// 0xccda5b cp_parser_translation_unit
// ../../gcc.git/gcc/cp/parser.cc:5469
// 0xccda5b c_parse_file()
// ../../gcc.git/gcc/cp/parser.cc:53949
// 0xe28481 c_common_parse_file()
// ../../gcc.git/gcc/c-family/c-opts.cc:1379
In a non-constexpr context the code otherwise works fine. Something seems to go
wrong with the reference binding (removing it fixes the problem).