https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102899

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> What I see is clang performing checks at a place it shouldn't.
> It can be better seen on
> struct Test {
>     constexpr Test() = default;
> 
>     constexpr ~Test() {
>         delete this;
>     }
> };
> 
> consteval bool test() {
>     auto obj = new Test();
>     delete obj;
>     return true;
> }
> 
> static_assert(test());
> where it reports
> destruction of object that is already being destroyed
> which definitely isn't something that happens in the testcase.
> The object is only destroyed after the destructor finishes, which is never
> in this case.

I think clang is right to reject this, because the constexpr destructor can
never be called with arguments that make it a constant expression, so it's
ill-formed; no diagnostic required ([dcl.constexpr]/6).

Reply via email to