]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix std::exception_ptr regressions [PR103630]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 9 Dec 2021 13:54:39 +0000 (13:54 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 12 Apr 2022 20:17:50 +0000 (21:17 +0100)
commit84e2410c8d10d7f3ca61c3063418ace8dd8f9e35
treea1c8d5c26fcafc873f0687bc4ff26108d9d03602
parentac0e9b696c362fdd49752260ca7b3ce9e467ec36
libstdc++: Fix std::exception_ptr regressions [PR103630]

This restores support for std::make_exception_ptr<E&> and for using
std::exception_ptr in C++98.

Because the new non-throwing implementation needs to use std::decay to
handle references the original throwing implementation is used for
C++98.

We also need to change the typeid expression so it doesn't yield the
dynamic type when the function parameter is a reference to a polymorphic
type. Otherwise the new exception object could be caught by any handler
matching the dynamic type, even though the actual exception object is
only a copy of the base class, sliced to the static type.

libstdc++-v3/ChangeLog:

PR libstdc++/103630
* libsupc++/exception_ptr.h (exception_ptr): Fix exception
specifications on inline definitions.
(make_exception_ptr): Decay the template parameter. Use typeid
of the static type.
* testsuite/18_support/exception_ptr/103630.cc: New test.

(cherry picked from commit a1ca039fc0fe934ef36c25d8284e6e116bcaffa7)
libstdc++-v3/libsupc++/exception_ptr.h
libstdc++-v3/testsuite/18_support/exception_ptr/103630.cc [new file with mode: 0644]