[Bug c++/99262] New: The decltype-specifier that denotes a destructor in a function call is rejected by GCC

xmh970252187 at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 25 08:00:02 GMT 2021


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

            Bug ID: 99262
           Summary: The decltype-specifier that denotes a destructor in a
                    function call is rejected by GCC
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

````cpp
int main(){
  int a = 0;
  a.~decltype(a)();
}
````
This usage is rejected by GCC<https://godbolt.org/z/dj98nb> while it's accepted
by Clang. as per [expr.prim.id#unqual-1], [expr.ref#6.3.2], and [expr.call#5]
> A type-name or decltype-specifier prefixed by ~ denotes the destructor of the type so named; see [expr.prim.id.dtor]. 

> If E2 is a (possibly overloaded) member function, function overload resolution ([over.match]) is used to select the function to which E2 refers. The type of E1.E2 is the type of E2 and E1.E2 refers to the function referred to by E2.
>> Otherwise (when E2 refers to a non-static member function), E1.E2 is a prvalue. The expression can be used only as the left-hand operand of a member function call ([class.mfct]). 

>If the postfix-expression names a destructor or pseudo-destructor ([expr.prim.id.dtor]), the type of the function call expression is void; 

It should be a valid usage.


More information about the Gcc-bugs mailing list