]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constexpr, array, private ctor [PR120800]
authorJason Merrill <jason@redhat.com>
Fri, 1 Aug 2025 02:58:43 +0000 (22:58 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 1 Aug 2025 02:58:43 +0000 (22:58 -0400)
commit000138675af3e1ee587b0fa17709ea62590860cb
tree811e1550685a3add05d7f9037524ef4ef4e7a6be
parente2544362bee00d5d7cd40598cf183f20beff3107
c++: constexpr, array, private ctor [PR120800]

Here cxx_eval_vec_init_1 wants to recreate the default constructor call that
we previously built and threw away in build_vec_init_elt, but we aren't in
the same access context at this point.  Since we already checked access,
let's just suppress access control here.

Redoing overload resolution at constant evaluation time is sketchy, but
should usually be fine for a default/copy constructor.

PR c++/120800

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_vec_init_1): Suppress access control.

gcc/testsuite/ChangeLog:

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

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