https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125336
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:cce6cc2a791b5617716568a7ae33ef5f71e313cd commit r17-602-gcce6cc2a791b5617716568a7ae33ef5f71e313cd Author: Marek Polacek <[email protected]> Date: Fri May 15 14:51:29 2026 -0400 c++: another constexpr nested empty object [PR125336] When looking into 125315 I came up with another test that crashes due to an empty object. It still crashes even after Jason's patch. Here we have a subobject nested in an empty object: {.w = {.v = TARGET_EXPR <f(s)>}} w's type is W, an empty union due to [[no_unique_address]], so init_subob_ctx clears the ctor, but then we recurse to {.v = TARGET_EXPR <f(s)>} with a null ctx->ctor so the call to get_or_insert_ctor_field in cxx_eval_bare_aggregate crashes. This fixes the crash similarly to c++/125315. no_unique_address18.C worked fine even before this patch because there we don't have an empty object. But let's test it also. PR c++/125336 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_bare_aggregate): Don't call get_or_insert_ctor_field when there is no CONSTRUCTOR. Assert is_empty_class. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/no_unique_address17.C: New test. * g++.dg/cpp2a/no_unique_address18.C: New test. Reviewed-by: Jason Merrill <[email protected]>
