public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99263] New: A qualified-id that denotes a destructor of a class type that is used as an operand of `typeid` is accepted by GCC
@ 2021-02-25  8:11 xmh970252187 at gmail dot com
  2021-02-25  9:43 ` [Bug c++/99263] " redi at gcc dot gnu.org
  2021-02-25  9:45 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: xmh970252187 at gmail dot com @ 2021-02-25  8:11 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/99263] A qualified-id that denotes a destructor of a class type that is used as an operand of `typeid` is accepted by GCC
  2021-02-25  8:11 [Bug c++/99263] New: A qualified-id that denotes a destructor of a class type that is used as an operand of `typeid` is accepted by GCC xmh970252187 at gmail dot com
@ 2021-02-25  9:43 ` redi at gcc dot gnu.org
  2021-02-25  9:45 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-02-25  9:43 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-02-25

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/99263] A qualified-id that denotes a destructor of a class type that is used as an operand of `typeid` is accepted by GCC
  2021-02-25  8:11 [Bug c++/99263] New: A qualified-id that denotes a destructor of a class type that is used as an operand of `typeid` is accepted by GCC xmh970252187 at gmail dot com
  2021-02-25  9:43 ` [Bug c++/99263] " redi at gcc dot gnu.org
@ 2021-02-25  9:45 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-02-25  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced (and corrected) testcase:

#include <typeinfo>
struct A{
    ~A(){}
};
int main(){
    auto t = typeid(A::~A).name();
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-25  9:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25  8:11 [Bug c++/99263] New: A qualified-id that denotes a destructor of a class type that is used as an operand of `typeid` is accepted by GCC xmh970252187 at gmail dot com
2021-02-25  9:43 ` [Bug c++/99263] " redi at gcc dot gnu.org
2021-02-25  9:45 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).