Open leni536 opened 9 months ago
It's not necessary to use a destroying operator delete
to hit this corner case:
struct A {
void operator delete(void *);
};
struct B {
void operator delete(void *);
};
struct C : A, B {
using A::operator delete;
using B::operator delete;
};
void foo(C* ptr) {
delete ptr;
}
Therefore the resolution shouldn't be specific to destroying delete.
CWG2805
Full name of submitter: Lénárd Szolnoki
Reference: [expr.delete]
https://github.com/cplusplus/draft/blob/4c76193e3d310ea5a18679ab86a54074fe1635e9/source/expressions.tex#L5855-L5884
Issue description:
Condiser the following code:
For the delete expression within
foo
the lookup for the deallocation function is not specified. There are two viable deallocation functions,void D::operator delete(D*, std::destroying_delete_t)
andvoid B::operator delete(B*, std::destroying_delete_t)
. None of the lookup rules apply in [expr.delete].It seems that it is assumed that the only way that multiple functions remain candidates at one of the last three points is when one function remains with a
size_t
parameter and the an other one remains without asize_t
parameter.Suggested resolution:
I have no strong opinion either way.
https://godbolt.org/z/88c4shErv
Currently gcc fails with ICE (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111776), clang treats this as ambiguous, MSVC selects the deallocation function that is declared last (depends on order
using B::operator delete;
and the function declaration inD
).