https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120716
Bug ID: 120716 Summary: ICE on https://eel.is/c++draft/expr.const#example-3 in C++23 Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- struct A { int *const &r; }; void foo (int x) { constexpr A a = { &x }; static_assert (a.r == &x); [&] { static_assert (a.r != nullptr); } (); } is invalid in C++23 and earlier, but we ICE on it: constexpr-ref2.C: In function ‘void foo(int)’: constexpr-ref2.C:6:24: error: modification of ‘<anonymous>’ from outside current evaluation is not a constant expression 6 | constexpr A a = { &x }; | ^ constexpr-ref2.C:7:22: error: non-constant condition for static assertion 7 | static_assert (a.r == &x); | ~~~~^~~~~ constexpr-ref2.C: In lambda function: constexpr-ref2.C:8:28: error: non-constant condition for static assertion 8 | [&] { static_assert (a.r != nullptr); } (); | ~~~~^~~~~~~~~~ constexpr-ref2.C:8:41: internal compiler error: Segmentation fault 8 | [&] { static_assert (a.r != nullptr); } (); | ^ 0x311458f internal_error(char const*, ...) ../../gcc/diagnostic-global-context.cc:517 0x1a097ef crash_signal ../../gcc/toplev.cc:321 0x818130 prune_lambda_captures ../../gcc/cp/lambda.cc:1882 0x818130 finish_lambda_function(tree_node*) ../../gcc/cp/lambda.cc:1942 0x1193a8a cp_parser_lambda_body ../../gcc/cp/parser.cc:12614 0x1193a8a cp_parser_lambda_expression ../../gcc/cp/parser.cc:11855 0x11951fc cp_parser_primary_expression ../../gcc/cp/parser.cc:6271