Never call a destroying operator delete when cleaning up from an
authorRichard Smith <richard@metafoo.co.uk>
Sat, 9 Jan 2021 00:41:31 +0000 (16:41 -0800)
committerRichard Smith <richard@metafoo.co.uk>
Sat, 9 Jan 2021 00:51:47 +0000 (16:51 -0800)
commitaab25fa7d853d6da960607310e2cd3e3a843d5a9
tree81b550803ab83312da52c9fe90b2b858c16f41e4
parentb02ca0969ea3f8147ae74d08e131f1bfe4f203d2
Never call a destroying operator delete when cleaning up from an
exception thrown during construction in a new-expression.

Instead, when performing deallocation function lookup for a
new-expression, ignore all destroying operator delete candidates, and
fall back to global operator delete if there is no member operator
delete other than a destroying operator delete.

Use of destroying operator delete only makes sense when there is an
object to destroy, which there isn't in this case. The language wording
doesn't cover this case; this oversight has been reported to WG21, with
the approach in this patch as the proposed fix.
clang/lib/Sema/SemaExprCXX.cpp
clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
clang/test/SemaCXX/cxx2a-destroying-delete.cpp