https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99263
Bug ID: 99263
Summary: A qualified-id that denotes a destructor of a class
type that is used as an operand of `typeid` is
accepted 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
#include <iostream>
struct A{
~A(){}
};
int main(){
std::cout<< typeid(A::~A).name();
}
````
In this usage, A::~A should be an invalid operand of typeid, as per
[https://timsong-cpp.github.io/cppwp/n4861/expr.prim.id#2]
> An id-expression that denotes a non-static data member or non-static member
> function of a class can only be used:
>> as part of a class member access in which the object expression refers to
>> the member's class57 or a class derived from that class, or
>> to form a pointer to member ([expr.unary.op]), or
>> if that id-expression denotes a non-static data member and it appears in an
>> unevaluated operand.
None of the contexts listed in the above list is satisfied by this usage.
Hence, take the `A::~A` as an operand of `typeid` should be considered as an
invalid usage.