]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: cxx_eval_array_reference and empty elem type [PR101194]
authorPatrick Palka <ppalka@redhat.com>
Thu, 1 Jul 2021 00:44:52 +0000 (20:44 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 11 May 2022 17:10:28 +0000 (13:10 -0400)
commit5fcedef529c7564b6485ab2893c08865798a66ec
tree327d469132b62e5ad212a00267cb65b0f9de6655
parent8a4cae03a2df50cf07c7ecedf1322e1257d0664e
c++: cxx_eval_array_reference and empty elem type [PR101194]

Here the initializer for x is represented as an empty CONSTRUCTOR due to
its empty element type.  So during constexpr evaluation of the ARRAY_REF
x[0], we end up trying to value initialize the omitted element at index 0,
which fails because the element type is not default constructible.

This patch makes cxx_eval_array_reference specifically handle the case
where the element type is an empty type.

PR c++/101194

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_array_reference): When the element type
is an empty type and the corresponding element is omitted, just
return an empty CONSTRUCTOR instead of attempting value
initialization.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit a688c284dd3848b6c4ea553035f0f9769fb4fbc9)
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/cpp0x/constexpr-empty16.C [new file with mode: 0644]