]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constexpr bit_cast with empty field
authorJason Merrill <jason@redhat.com>
Fri, 14 Jul 2023 16:25:51 +0000 (12:25 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 18 Jul 2023 15:47:08 +0000 (11:47 -0400)
commitb41a927bcbdf27723b9d420f0b403f2af12129f1
treeeec708d18d291717fad6fe1fb6c35c2c4e37eda1
parentb80e3c468e373cc6fd4e41a5879dbca95a40ac8c
c++: constexpr bit_cast with empty field

The change to only cache constexpr calls that are
reduced_constant_expression_p tripped on bit-cast3.C, which failed that
predicate due to the presence of an empty field in the result of
native_interpret_aggregate, which reduced_constant_expression_p rejects to
avoid confusing output_constructor.

This patch proposes to skip such fields in native_interpret_aggregate, since
they aren't actually involved in the value representation.

gcc/ChangeLog:

* fold-const.cc (native_interpret_aggregate): Skip empty fields.

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_bit_cast): Check that the result of
native_interpret_aggregate doesn't need more evaluation.
gcc/cp/constexpr.cc
gcc/fold-const.cc