Implement P0722R3, destroying operator delete

Programming / Compilers / GCC - jason [138bc75d-0d04-0410-961f-82ee72b054a4] - 13 November 2018 04:40 EST

A destroying operator delete takes responsibility for calling the destructor for the object it is deleting; this is intended to be useful for sized delete of a class allocated with a trailing buffer, where the compiler can't know the size of the allocation, and so would pass the wrong size to the non-destroying sized operator delete.

gcc/c-family/
- c-cppbuiltin.c (c_cpp_builtins): Define __cpp_impl_destroying_delete. gcc/cp/
- call.c (std_destroying_delete_t_p, destroying_delete_p): New. (aligned_deallocation_fn_p, usual_deallocation_fn_p): Use destroying_delete_p. (build_op_delete_call): Handle destroying delete.
- decl2.c (coerce_delete_type): Handle destroying delete.
- init.c (build_delete): Don't call dtor with destroying delete.
- optimize.c (build_delete_destructor_body): Likewise. libstdc++-v3/
- libsupc++/new (std::destroying_delete_t): New.

76b94d4ba65 Implement P0722R3, destroying operator delete.
gcc/c-family/ChangeLog | 3 ++
gcc/c-family/c-cppbuiltin.c | 1 +
gcc/cp/ChangeLog | 9 +++++
gcc/cp/call.c | 45 +++++++++++++++++++++++++
gcc/cp/cp-tree.h | 3 +-
gcc/cp/decl.c | 2 +-
gcc/cp/decl2.c | 32 ++++++++++++++----
gcc/cp/init.c | 8 ++++-
gcc/cp/optimize.c | 27 ++++++++++-----
gcc/testsuite/g++.dg/cpp2a/destroying-delete1.C | 41 ++++++++++++++++++++++
gcc/testsuite/g++.dg/cpp2a/feat-cxx2a.C | 4 +++
libstdc++-v3/ChangeLog | 4 +++
libstdc++-v3/libsupc++/new | 12 +++++++
13 files changed, 174 insertions(+), 17 deletions(-)

Upstream: gcc.gnu.org


  • Share