public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115470] New: bad_typeid is not thrown for typeid(*null pointer) of final class
@ 2024-06-13  5:40 user202729 at protonmail dot com
  2024-06-13  7:49 ` [Bug c++/115470] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: user202729 at protonmail dot com @ 2024-06-13  5:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115470
           Summary: bad_typeid is not thrown for typeid(*null pointer) of
                    final class
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: user202729 at protonmail dot com
  Target Milestone: ---

For the following code, gcc does nothing, while clang throws a bad_typeid.

#include<typeinfo>

struct D {
    virtual void f() {}
};

struct C final : D {
};

void h(){
    typeid(*(C*)0);
}

Godbolt link: https://godbolt.org/z/GohvfMMhr

Clang does throw a bad_typeid exception.

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

* [Bug c++/115470] bad_typeid is not thrown for typeid(*null pointer) of final class
  2024-06-13  5:40 [Bug c++/115470] New: bad_typeid is not thrown for typeid(*null pointer) of final class user202729 at protonmail dot com
@ 2024-06-13  7:49 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-13  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-06-13
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

I think the issue is the check:
  if (TYPE_POLYMORPHIC_P (TREE_TYPE (exp))
      && ! resolves_to_fixed_type_p (exp, &nonnull)
      && ! nonnull)


is wrong here in that the resolves_to_fixed_type_p is not exactly correct.

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

end of thread, other threads:[~2024-06-13  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-13  5:40 [Bug c++/115470] New: bad_typeid is not thrown for typeid(*null pointer) of final class user202729 at protonmail dot com
2024-06-13  7:49 ` [Bug c++/115470] " pinskia 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).