Bug 77815 - access to destructor via decltype-specifier
Summary: access to destructor via decltype-specifier
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 99262 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-10-01 21:36 UTC by Jeff Mirwaisi
Modified: 2024-08-19 14:59 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-04-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Mirwaisi 2016-10-01 21:36:36 UTC
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'
Comment 1 Jonathan Wakely 2016-10-03 10:51:54 UTC
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();
Comment 2 Andrew Pinski 2021-08-05 02:24:36 UTC
*** Bug 99262 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Pinski 2024-08-19 14:44:13 UTC
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1586

Say this is invalid code after all ...
Comment 4 Jonathan Wakely 2024-08-19 14:58:28 UTC
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.