<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118660>118660</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang considers destructor in noexcept expression that should call destroying delete
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AlisdairM
</td>
</tr>
</table>
<pre>
When a destroying delete function is called, the pointed-to object's destructor is not run --- it is the responsibility of the destroying delete function to run any destructors. However, when querying the noexcept operator for such a delete expression, Clang is considering the exception specification of the destructor, even though at runtime it clearly performs the right code.
#include <cstdio>
#include <new>
struct Explicit {
~Explicit() noexcept(false) { puts("should not be called");}
void operator delete(Explicit*, std::destroying_delete_t) noexcept {
std::puts("destroyed explicit");
}
};
// #define SHOW_BUGS
#if defined(SHOW_BUGS)
Explicit * qn = nullptr;
static_assert( noexcept(delete(qn)));
#endif
int main() {
Explicit *q = new Explicit();
delete q;
}
Here us a Compiler Explorer link to a more complete test, that passed on EDG even with the SHOW_BUGS macro defined:
https://godbolt.org/z/YaaeT8W17
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VM-P6jYQ_mucywiU2ECSQw7ssry9VD28VqueVo49IW4dO9gOLD30b6-cBMLrkypFAo8933zzzQ_uvToZxIpsX8j2kPAhtNZVe6285Mr9ktRW3qqPFg1wkOiDszdlTiBRY0BoBiOCsgaUB8G1RknoK4QWobfKBJSrYMHWf6IIhOZ-QhhEsC56GBvADQZWqxWoEC3R06HvrfGqVlqFG9hmtP5P7GBHFG5uT_h-DfBur3hBFyldYwbnAd2IEAGNxS-BfQDbo-ORUWMd-EG0Y6ZjCPzqHXqvrIkYr5qb05hppCfR3aEmoEjF9yhUowQfT8_UR1IRBS9oILR2OLXAx_yD6jDmLzRyp2_Qo2us62Y11KkNIKzENUn38aNMGaEHiUDYq_BBKkvY2083Bq-zOd1P8eHtq9dKq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