https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117614
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:7ae55c2f73626e8a7a6871a1e4fd4cde2e6c8460 commit r14-11153-g7ae55c2f73626e8a7a6871a1e4fd4cde2e6c8460 Author: Jakub Jelinek <ja...@redhat.com> Date: Wed Dec 11 17:28:47 2024 +0100 c++: allow stores to anon union vars to change current union member in constexpr [PR117614] Since r14-4771 the FE tries to differentiate between cases where the lhs of a store allows changing the current union member and cases where it doesn't, and cases where it doesn't includes everything that has gone through the cxx_eval_constant_expression path on the lhs. As the testcase shows, DECL_ANON_UNION_VAR_P vars were handled like that too, even when stores to them are the only way how to change the current union member in the sources. So, the following patch just handles that case manually without calling cxx_eval_constant_expression and without setting evaluated to true. 2024-12-11 Jakub Jelinek <ja...@redhat.com> PR c++/117614 * constexpr.cc (cxx_eval_store_expression): For stores to DECL_ANON_UNION_VAR_P vars just continue with DECL_VALUE_EXPR of it, without setting evaluated to true or full cxx_eval_constant_expression. * g++.dg/cpp2a/constexpr-union8.C: New test. (cherry picked from commit 337815c8bbd0fb5034223ad0e7899d1493e958a2)