https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98988
Bug ID: 98988
Summary: delete is not a constant expression with
-fsanitize=undefined
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: david at doublewise dot net
Target Milestone: ---
The following valid translation unit:
```
constexpr bool f() {
auto ptr = new int();
delete ptr;
return true;
}
static_assert(f());
```
is incorrectly rejected when compiled with `-fsanitize=undefined`, complaining
about
```
<source>:7:16: error: non-constant condition for static assertion
7 | static_assert(f());
| ~^~
<source>:7:16: in 'constexpr' expansion of 'f()'
<source>:3:9: error: '(((int*)(& heap )) != 0)' is not a constant expression
3 | delete ptr;
| ^~~~~~~~~~
Compiler returned: 1
```
See it live: https://godbolt.org/z/Yf67G7