[Bug c++/117614] [14/15 Regression] Cannot change active member of anonymous union in constant expression since r14-4771-g1d260ab0e39ea6
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 11 16:29:22 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117614
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:337815c8bbd0fb5034223ad0e7899d1493e958a2
commit r15-6119-g337815c8bbd0fb5034223ad0e7899d1493e958a2
Author: Jakub Jelinek <jakub@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 <jakub@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.
More information about the Gcc-bugs
mailing list