<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57075>57075</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
global ”operator delete“ issue when -O2 optimization using clang12+ version
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chumarshal1
</td>
</tr>
</table>
<pre>
```
#include<iostream>
void operator delete(void *p) noexcept
{
std::cout << "===call delete====" << std::endl;
}
int test()
{
int *p = new int;
::delete p;
return 1;
}
int main()
{
test();
std::cout << "===test====" << std::endl;
}
```
test it using https://godbolt.org/
clang12.0.0 -O0
```
===call delete====
===test====
```
clang12.0.0 -O2
```
Program returned: 132
```
clang11.0.1 -O2
```
===test====
```
gcc -O2
```
===test====
```
Process finished with exit code 132, when using clang12 -O2, but gcc is OK and clang11 is OK.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVE1z2yAQ_TXowkQjwLKkgw5xnFx6SP8CgrVEBwsPoCTtr-8iyWniuun0w7Mj4d3lvbesls7pry3ZFqsVe1LcEi7MqOykgYg740L0II9E3C_RJ2c0dSfwMjpPNViIQHg9uwm_PRHe0NHBi4JTXPGq3bKg-AtRE3GLptwUKRKg4T5OxH4xJa09w559yTin5_RXDBi1JWJ3ptmvi_lpxkgjhIjaUNIVJSkhCUbUPR3hOTlewVLCwrFIoad3IQ9x8iNlH5EfpRkXcnqF_Y008SfHM-_7l3O5bPb8TKjURDoFM_Z0iPEUEhJ_QOud7pyNufN9crzZpawce8bzIi9Q-s1jcZ3hd519n_VTgb9WfcnPr-Z-9q738rj2DNIRUSau577FZYjLPsD9G8W9Uv8ZEatTEAI9mNGEATR9NnGg8ILNVE7DXCm_o88DjGt311NbZGCoww8t6TKBPn6ictRrBls8-cKTQcu224IXtWhEpluhG9HILJpooe2t66Sl5J6TuiDN_vJ6WP13OHQhTLCoQXq8R6I5mm8yGnchj_AdfQIfMJBN3rYX3yQWOXW5ckf8Y-3T-XVz8u4LKJysh5kp4KKsiqrMhnZTHhQ_VApU1XWVYOpQdUJwxUTZaLmtMys7sKEl5Q6Har4QEkQavnKfmZYXHKtnrKjLpuS5xq1bXdVis2E11A3ZFIAjb_OkIw1L5ttZUjf1AYPWhBh-BGUIph8BZjrEl1McnG_VMB2lD4O0LJvp21n-d34ThNk">