]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Implement C++26 P3144R2 - Deleting a Pointer to an Incomplete Type Should be...
authorJakub Jelinek <jakub@redhat.com>
Tue, 2 Jul 2024 20:08:45 +0000 (22:08 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 2 Jul 2024 20:08:45 +0000 (22:08 +0200)
commitbeb7a418aaef2ec8a812712110b007c091a73491
tree088bc7eefe435ab66e20bc74bb34fe987f72a559
parentf30bdb1f2d79fd787e0c270039179bf80830161f
c++: Implement C++26 P3144R2 - Deleting a Pointer to an Incomplete Type Should be Ill-formed [PR115747]

The following patch implements the C++26 paper which makes delete
and delete[] on incomplete class types invalid, previously it has
been UB unless the class had trivial destructor and no custom
deallocator.

The patch uses permerror_opt, so -Wno-delete-incomplete makes it
still compile without warnings like before, and -fpermissive makes
it warn but not error; in SFINAE contexts it is considered an error
in C++26 and later.

2024-07-02  Jakub Jelinek  <jakub@redhat.com>
    Jason Merrill  <jason@redhat.com>

PR c++/115747
gcc/cp/
* init.cc: Implement C++26 P3144R2 - Deleting a Pointer to an
Incomplete Type Should be Ill-formed.
(build_vec_delete_1): Emit permerror_at and return error_mark_node
for delete [] on incomplete type.
(build_delete): Similarly for delete.
gcc/testsuite/
* g++.dg/init/delete1.C: Adjust expected diagnostics for C++26.
* g++.dg/warn/Wdelete-incomplete-1.C: Likewise.
* g++.dg/warn/incomplete1.C: Likewise.
* g++.dg/ipa/pr85607.C: Likewise.
* g++.dg/cpp26/delete1.C: New test.
* g++.dg/cpp26/delete2.C: New test.
* g++.dg/cpp26/delete3.C: New test.
gcc/cp/init.cc
gcc/testsuite/g++.dg/cpp26/delete1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp26/delete2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp26/delete3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/init/delete1.C
gcc/testsuite/g++.dg/ipa/pr85607.C
gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C
gcc/testsuite/g++.dg/warn/incomplete1.C