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

    <tr>
        <th>Summary</th>
        <td>
            clang places calls to operator delete even for noexcept constructors
        </td>
    </tr>

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

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

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

<pre>
    Unlike gcc, clang always turns compiler placed calls to operator delete for exception handling into hard errors if operator delete was marked deleted. gcc instead simply leaves out the call to operator delete in this situation. Issue of which compiler is conforming to the standard in this case aside, this is a huge problem for clang, because it is unable to see that noexcept constructors will never throw, which means you can't mark a constructor noexcept to prevent clang from putting that call to operator delete in there, which becomes a compilation breaking error if you want to delete operator delete for that class/struct:

```
#include <new>
#include <cinttypes>

struct Allocation {
    Allocation() noexcept;
 void operator delete(void*) = delete;
    void operator delete(void*, size_t) = delete;
};

int main() {
    Allocation* volatile pointer = new Allocation();
}
```

> clang++ -std=c++14 -emit-llvm -pedantic -c new.cpp


```cpp
#include <new>
#include <cinttypes>

struct Allocation {
    Allocation() noexcept;
    void operator delete(void*) = delete;
    void operator delete(void*, size_t) = delete;
};

int main() {
    Allocation* volatile pointer = new Allocation();
}
```
> clang++ -std=c++14 -emit-llvm -pedantic -c new.cpp
> new.cpp:11:40: error: attempt to use a deleted function
>     Allocation* volatile pointer = new Allocation();
>                           ^
> new.cpp:6:10: note: 'operator delete' has been explicitly marked deleted here
>     void operator delete(void*) = delete;
>          ^
> 1 error generated.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVl-P6rYT_TTmZQQKDiHwkAf2n_R7_t0-VxN7IO46dmRPlks_fWUHluUu21bVlSoVIScZ22fOzLFmjDGagyNqRPUgqqcZjtz50Hzr6P8dhR7dN3SvFGat16fmF2fNK8FBKSEfQVl0B0B7xFMEHoOLo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