This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


2805. Underspecified selection of deallocation function

Section: 7.6.2.9  [expr.delete]     Status: open     Submitter: Lénárd Szolnoki     Date: 2023-10-12

Consider:

  #include <memory>

  struct B {
    void operator delete(B* ptr, std::destroying_delete_t);
  };

  struct D : B {
    void operator delete(D* ptr, std::destroying_delete_t);
    using B::operator delete;
  };

  void foo(D* ptr) {
    delete ptr;
  }

The selection rules in 7.6.2.9 [expr.delete] paragraph 10 do not disambiguate this case. There is implementation divergence.

A similar situation arises for the following example:

  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;
  }

CWG 2023-10-20

The ordered list of preferences should be retained. Eventual disambiguation should be via overload resolution, but it is unclear how to deal with the unspecified choice between overloads with and without a std::size_t parameter.