https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118225
Bug ID: 118225 Summary: ICE: in build_class_member_access_expr, at cp/typeck.cc:2983 Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: ice-checking, ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rush102333 at gmail dot com Target Milestone: --- struct NoMut1 { int a, b; }; struct NoMut3 : virtual NoMut1 { constexpr NoMut3(int a, int b) : NoMut1{a, b} {} }; void mutable_subobjects() { constexpr NoMut3 nm3 = {1, 2}; struct A { void f() { static_assert(nm3.a == 1, ""); } }; } $ g++ -freport-bug err_mut18.cpp <source>: In constructor 'constexpr NoMut3::NoMut3(int, int)': <source>:3:50: error: 'struct NoMut3' has virtual base classes 3 | constexpr NoMut3(int a, int b) : NoMut1{a, b} {} | ^ <source>: In function 'void mutable_subobjects()': <source>:6:31: error: call to non-'constexpr' function 'constexpr NoMut3::NoMut3(int, int)' 6 | constexpr NoMut3 nm3 = {1, 2}; | ^ <source>:3:13: note: 'constexpr NoMut3::NoMut3(int, int)' declared here 3 | constexpr NoMut3(int a, int b) : NoMut1{a, b} {} | ^~~~~~ <source>: In member function 'void mutable_subobjects()::A::f()': <source>:9:21: error: use of local variable with automatic storage from containing function 9 | static_assert(nm3.a == 1, ""); | ^~~ <source>:6:20: note: 'constexpr const NoMut3 nm3' declared here 6 | constexpr NoMut3 nm3 = {1, 2}; | ^~~ <source>:9:25: internal compiler error: in build_class_member_access_expr, at cp/typeck.cc:2983 9 | 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 0xdc2042 finish_class_member_access_expr(cp_expr, tree_node*, bool, 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. Compiler Explorer: https://godbolt.org/z/53GGTM381