public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/105387] libstdc++: with -fno-rtti, pointer type info class incorrectly matches non-pointer type info classes
Date: Sat, 05 Nov 2022 14:03:43 +0000	[thread overview]
Message-ID: <bug-105387-4-FjafBevF2S@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105387-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:b83f01d0057578ebc1785f858fbfd46cdc210560

commit r13-3696-gb83f01d0057578ebc1785f858fbfd46cdc210560
Author: Jakob Hasse <0xjakob@users.noreply.github.com>
Date:   Tue Apr 26 12:03:47 2022 +0800

    libstdc++: fix pointer type exception catch (no RTTI) [PR105387]

    __pbase_type_info::__do_catch(), used to catch pointer type exceptions,
    did not check if the type info object to compare against is a pointer
    type info object before doing a static down-cast to a pointer type info
    object. If RTTI is disabled, this leads to the following situation:
    Since a pointer type info object has additional fields, they would
    end up being undefined if the actual type info object was not a pointer
    type info object.

    A simple check has been added before the down-cast happens.

    Note that a consequence of this check is that exceptions of type
    pointer-to-member cannot be caught anymore.

    In case RTTI is enabled, this does not seem to be a problem because
    RTTI-based checks would run before and prevent running into the bad
    down-cast. Hence, the fix is disabled if RTTI is enabled and exceptions
    of type pointer-to-member can still be caught.

    libstdc++-v3/ChangeLog:

            PR libstdc++/105387
            * libsupc++/pbase_type_info.cc (__do_catch) [!__cpp_rtti]: Add
            check that the thrown type is actually a pointer.
            * testsuite/18_support/105387.cc: New test.
            * testsuite/18_support/105387_memptr.cc: New test.

    Signed-off-by: Jakob Hasse <jakob.hasse@espressif.com>

  parent reply	other threads:[~2022-11-05 14:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26  8:58 [Bug c++/105387] New: " jakob2811 at hotmail dot de
2022-04-26  9:03 ` [Bug c++/105387] " rguenth at gcc dot gnu.org
2022-04-26  9:07 ` jakub at gcc dot gnu.org
2022-04-28  1:57 ` [Bug libstdc++/105387] " jakob2811 at hotmail dot de
2022-05-04 22:18 ` redi at gcc dot gnu.org
2022-11-05 14:03 ` cvs-commit at gcc dot gnu.org [this message]
2022-11-05 14:05 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105387-4-FjafBevF2S@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).