aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorJakob Hasse <0xjakob@users.noreply.github.com>2022-04-26 12:03:47 +0800
committerJonathan Wakely <jwakely@redhat.com>2022-11-05 14:03:08 +0000
commitb83f01d0057578ebc1785f858fbfd46cdc210560 (patch)
tree8c24796d5e642fb83dd49271cb7b29f76329b5f1 /libcpp
parent7c6008e75df80607f8104e665e0448a0a9cbf85a (diff)
downloadgcc-b83f01d0057578ebc1785f858fbfd46cdc210560.zip
gcc-b83f01d0057578ebc1785f858fbfd46cdc210560.tar.gz
gcc-b83f01d0057578ebc1785f858fbfd46cdc210560.tar.bz2
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>
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions