Invocation of the destructor or pseudo destructor via a decltype-specifier results in an error: T t; t.~decltype(t)(); error: expected identifier before 'decltype'
That's not a valid testcase, please read https://gcc.gnu.org/bugs/ again. Confirmed for: void f() { struct T { }; T t; t.~decltype(t)(); } As a workaround you can define a new alias and use that in the pseudo-destructor-name: using U = decltype(t); t.~U();
*** Bug 99262 has been marked as a duplicate of this bug. ***
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1586 Say this is invalid code after all ...
In that Core issue, the type of *p is a reference. In comment 1 the type of t is not a reference, it's just T, so it should work. Clang and EDG accept it.