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

    <tr>
        <th>Summary</th>
        <td>
            virtual function calls for functions marked `[[gnu::const]]` get optimized away
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    GCC calls the virtual destructor for
```
struct S {
  [[gnu::const]] virtual ~S();
};

void destroy(S* s) {
  s->~S();
}
```
([Godbolt](https://godbolt.org/z/sbx4fz68M)) while clang optimizes it away. Since `[[gnu::const]]` is a GCC extension clang should emulate the behaviour.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFUUlu4zAQfA11ISLQpLUddLDjJKec_AIuLYkJLRpcnNivH4q2k8FgggClpdnd1cUuYdW5f3l8xJIb43GYAJ-0C5EbrMAHF2WwDg_WIbJDZINqckMOrwV4j1GzvZ5gjKptwjhHxDYJ0s4-oGqX8MWMmqc9oi2iHWK3PtTsvv_z-2S1umqw51ScGjbYp5a_Z_kHxJ5-YPuf3qWs2r5YJazJomg7hXD0i1T6nDBeU6V1Y4ou6fHicz1c6vZ14U_TPyZtAEvD5xHbY9AHfQGPdcD8g59LvNezBLwM_HENKYm1xxwva4fPALPXdr5R-slGozAcouEBsh8CJn7SNrqygH5VV123WjWMFapnqmMdL4IOBvr7coc4y5AJs6PDYt_tyOMDd--gftc3Qvi6ncpXK6Iz_T_L0mGKopT2kAJjTvfPw9HZN5Ahhdr7CMm156ru2qaYelgp0UmieDcM1VoQARIkkeu2qTq5GobCcAHG91nertA9JZSSljSUsorRsmOyVlC3VLJaMMLQmsCBa1MugxfbCtdnDSKOPiWN9sF_J7n3epwB7vw8hsm6_phMnfV70zRFVtxnuX8AzkTw9g">