]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constexpr union member access folding [PR114709]
authorPatrick Palka <ppalka@redhat.com>
Wed, 24 Apr 2024 21:49:56 +0000 (17:49 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 24 Apr 2024 21:49:56 +0000 (17:49 -0400)
commit0844170e9ef60a8b2f6fba6786672f30ce1c2749
tree39e99ce4ad16c8754283b51ee955ae9032c017d3
parent97a54c05b8e338e673e1f7fb72c0e23abb571c60
c++: constexpr union member access folding [PR114709]

The object/offset canonicalization performed in cxx_fold_indirect_ref
is undesirable for union member accesses because it loses information
about the member being accessed which we may later need to diagnose an
inactive-member access.  So this patch restricts the canonicalization
accordingly.

PR c++/114709

gcc/cp/ChangeLog:

* constexpr.cc (cxx_fold_indirect_ref): Restrict object/offset
canonicalization to RECORD_TYPE member accesses.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-union8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/cpp0x/constexpr-union8.C [new file with mode: 0644]