<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/76269>76269</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Cannot use destroying operator delete in constant expressions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Fedr
      </td>
    </tr>
</table>

<pre>
    This program with destroying operator delete in a constant expression is accepted by GCC and MSVC:
```
#include <new>

struct A {
    constexpr void operator delete(A *, std::destroying_delete_t);
};

struct B : A {};

constexpr void A::operator delete(A *p, std::destroying_delete_t) {
 static_cast<B*>(p)->~B();
    ::delete p;
}

constexpr bool foo() {
    A *p = new B;
    delete p;
    return true;
}

static_assert( foo() ); 
```

Unfortunately, Clang complains:
```
error: constexpr function never produces a constant expression [-Winvalid-constexpr]
note: call to class-specific 'operator delete'
```
Online demo: https://godbolt.org/z/98G834Tvn
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE2P8jYQ_jWTy4hVGMMmOeQA7OY9VT30bXtcOfYArowd2RO220N_e5VAu5-or4RMYjvPx8yj0Tm7Q2BuYb2F9UOhRznG1HZsU9FH-9J-P7qMQ4qHpE_47OSIlrOk-OLCAePASUtMaNmzMLqAGk0MWXQQ5D-HxDm7GNBl1MbwIGyxf8Fvux3qYPGnX37bgdpA-QDlBu7L6-_ySsoF40fLCGoX-BnU4_VkXrOk0QhuEKrtZQcRL-QTMZ6jsx8FAtUbBNoA7TCLnajV5tXP0-XWkwA1oK6oUD28Pr9l3iKozZX_050POjYXqhtyhh_Q88ZmFi3OPBmdBdRuO_lRj0D1ANQsQD3-vQWq31qYCvMv9tyn4Z27L2X3MXrcx3iBel_ki2gE9YCBn3H7jugTxbSZWMYUUNLIt6ivrnTOnASofks-e8GvYzKvv4Z9TDIGLexfpmruvA4HNPE0eO1CvhUyTimmqY2vxvdjMDJlNvCZ0xR9OxrON4IN6-3idxfO2ju7-A8E1ldrIQrP8Np7lIjG65wXeWDj9s4gUPUpEtWXQn8O3gVGy6c44R1FhtkUdUDdIdo-ermL6QDU_QXUNfW3Wq2-n0NhW2Ub1eiC22VVKqqa9ZqKY2t705u6Wqla7ctyyWtVqyWtGmNrc2_runAtlaSWRETLJSm6M1Tum0oZq2yl1ryHVckn7fyd9-fTxF24nEduq3u6bwqve_Z5HitEU0rmQyCapkxqp28W_XjIsCq9y5JfUcSJ53anQ4iCY-b_GThfdCUXY_Lthxo5OY79nYknoG7iuv4thhT_YCNA3awwA3Wzg38CAAD__81zjNY">