https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120577
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:f23b5df56e237df9f66b615ca4babc564d5f75de commit r16-2265-gf23b5df56e237df9f66b615ca4babc564d5f75de Author: Jason Merrill <ja...@redhat.com> Date: Sat Jul 12 05:15:01 2025 -0400 c++: constexpr uninitialized union [PR120577] This was failing for two reasons: 1) We were wrongly treating the basic_string constructor as zero-initializing the object, which it doesn't. 2) Given that, when we went to look for a value for the anonymous union, we concluded that it was value-initialized, and trying to evaluate that broke because we weren't setting ctx->ctor for it. This patch fixes both issues, #1 by setting CONSTRUCTOR_NO_CLEARING and #2 by inserting a new CONSTRUCTOR for the member rather than evaluate it out of context, which is consistent with cxx_eval_store_expression. PR c++/120577 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_call_expression): Set CONSTRUCTOR_NO_CLEARING on initial value for ctor. (cxx_eval_component_reference): Make value-initialization of an aggregate member explicit. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-union9.C: New test.