]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constexpr, array, private ctor [PR120800]
authorJason Merrill <jason@redhat.com>
Thu, 31 Jul 2025 18:23:31 +0000 (14:23 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 31 Jul 2025 18:23:31 +0000 (14:23 -0400)
commitdf63b4a2f77acd6d10aad68fdfbf4d5b698dad5b
tree977db912c33d4cdd1f72fc455a3d1c92e300aa84
parent4cdf85859b8d19b91de8f2226fc0f0d79b3f2dbb
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]