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>
Thu, 9 Dec 2021 23:02:37 +0000 (23:02 +0000)
commita1ca039fc0fe934ef36c25d8284e6e116bcaffa7
tree0130f298f5e76dbc46ce7501c8e099dddf7a709d
parenta219139e986a4200a9105d7c1fa63735d2945994
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.
libstdc++-v3/libsupc++/exception_ptr.h
libstdc++-v3/testsuite/18_support/exception_ptr/103630.cc [new file with mode: 0644]