https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118193
Bug ID: 118193
Summary: ICE: in verify_ctor_sanity, at cp/constexpr.cc:5362
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: wangbopku15 at gmail dot com
Target Milestone: ---
The following code triggers an ICE on gcc since version 12.2.0:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct empty{
};
struct NoMut1 : empty{ int a, b; };
struct NoMut3 : NoMut1 {
constexpr NoMut3(int a, int b){}
};
void mutable_subobjects() {
constexpr NoMut3 nm3 = {1, 2};
struct A{
void f() {
static_assert(nm3.a == 1, "");
}
};
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please see Compiler Explorer: https://godbolt.org/z/rbhrPhvor.
It's also worth noting that the empty base class here is necessary to trigger
the bug.
Compiler Output:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>: In member function 'void mutable_subobjects()::A::f()':
<source>:12:25: internal compiler error: in verify_ctor_sanity, at
cp/constexpr.cc:5362
12 | static_assert(nm3.a == 1, "");
| ~~~~^
0x2938075 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x294ee76 internal_error(char const*, ...)
???:0
0xacaf50 fancy_abort(char const*, int, char const*)
???:0
0xb444f2 maybe_constant_value(tree_node*, tree_node*, mce_value)
???:0
0xdb2c47 cp_build_binary_op(op_location_t const&, tree_code, tree_node*,
tree_node*, int)
???:0
0xb03c74 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node**, int)
???:0
0xda41e2 build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node*, tree_node**, int)
???:0
0xce5603 c_parse_file()
???:0
0xe450d9 c_common_parse_file()
???:0
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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~