]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: CTAD and constexpr ctor [PR115207]
authorJason Merrill <jason@redhat.com>
Fri, 2 May 2025 12:35:38 +0000 (08:35 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 2 May 2025 13:39:02 +0000 (09:39 -0400)
commit2d7a0d38e2f8e281ab2269cfe6c048410fa3c886
tree1ebebc389560f897acfa8b32917563ae77b703bb
parentb7e77644d1b27810c5db1944644b6c5eca74cf93
c++: CTAD and constexpr ctor [PR115207]

Here we failed to constant-evaluate the A<int> constructor because DECL_SIZE
wasn't set on 'a' yet, so compare_address thinks we can't be sure it isn't
at the same address as 'i'.

Normally DECL_SIZE is set by build_decl calling layout_decl, but that
doesn't happen here because we don't have a type yet.  So we need to
layout_decl again after deduction.

PR c++/115207

gcc/cp/ChangeLog:

* decl.cc (cp_finish_decl): Call layout_decl after CTAD.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction118.C: New test.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/cpp1z/class-deduction118.C [new file with mode: 0644]