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

    <tr>
        <th>Summary</th>
        <td>
            clang can't successfully destroy an integer variable via a pseudo destructor
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            constexpr
      </td>
    </tr>

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

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

<pre>
    This code:

```c++
  typedef int I;

  constexpr int foo() {
 int k = 0;
    k.~I();
    return 0;
  }
```

should probably work, GCC and MSVC accept it: https://godbolt.org/z/MavW6o7ox

And clang's diagnostic seem bogus:

```console
./array.cpp:231:17: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  231 | constexpr int foo() {
      |                 ^~~
./array.cpp:232:9: note: destroying object 'k' whose lifetime has already ended
  232 | int k = 0;
      |         ^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU02P4ygQ_TXlS6kju4jt-OBDOpms5jCnXe2cMZQdtglYgDOTPfRvX5H0Z6SWFqHEKh7Fe6-qZIxmcsw91I9Q7wu5pKMPfRokaw6hGLy-9H8dTUTlNYPYQrmH8vW3KW9bAT3mfY0ipsvMmkc0LuF3EI8f7yAq72Li33O4no_eA22AOoT2NUGOPyGIPZZvtxERn1bP32_gT-HAaQnuExba_R3Fjxzi0S9W4xz8IAd7wV8-PAHt8I_dDqXT-OPPv3coleI5oUkgtnhMaY5ZPR2ADpPXg7dp5cMEdPgX6PBDnn82vvW_Pz6zdRqVlW4CaiNqIyfnYzIKI_MJBz8t8UtDvYve8i26AjrIEORlpeYZxJZEBWJbtZkYh-BD_nh3dVycSsY7dHzmkFXqRXFEecNIlzDjOMYMgvrx4adxZ2mNfnhLAvX-1UoSFUK7-x9lu64MvV9Qf3t-_koLgdh2WYHzKTcYao4p-ItxE_rhH1YJgdonoBZ_HX1ktGbkZE6MRxlR2sBSX5CdZv1Oma48vuqjzyyh_nbnfqF7oTvRyYL7qqXNuq5LEsWxl6JumkpV1bCmtuS1Vu2mbJqx3pStLmVbmJ5KWldl2ZUNiTWtZDd2a12X7WbkkboG1iWfpLEra8-n3ECFiXHhvqqqRnSFlQPbeB1GolvviO0YvEvsNBAB7fLBW5mI8tCGPmd7GJYpwrq0Jqb4nj-ZZLm_5kIlHVCbMC5KcYzjYu3l1W-ULhvGEwc8y2DkYBnPRqLEOfKi_Q24qORDsQTb382EScdlWCl_Ajrkx1_-HubgcxGBDlelEejwIvbc038BAAD___PEUvE">