Issue 76269
Summary Cannot use destroying operator delete in constant expressions
Labels new issue
Assignees
Reporter Fedr
    This program with destroying operator delete in a constant _expression_ is accepted by GCC and MSVC:
```
#include <new>

struct A {
    constexpr void operator delete(A *, std::destroying_delete_t);
};

struct B : A {};

constexpr void A::operator delete(A *p, std::destroying_delete_t) {
 static_cast<B*>(p)->~B();
    ::delete p;
}

constexpr bool foo() {
    A *p = new B;
    delete p;
    return true;
}

static_assert( foo() ); 
```

Unfortunately, Clang complains:
```
error: constexpr function never produces a constant _expression_ [-Winvalid-constexpr]
note: call to class-specific 'operator delete'
```
Online demo: https://godbolt.org/z/98G834Tvn
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to