1 // { dg-do run { target c++11 } }
3 // 2008-05-25 Sebastian Redl <sebastian.redl@getdesigned.at>
5 // Copyright (C) 2008-2024 Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // rethrow_exception() and preservation of data
28 #include <testsuite_hooks.h>
35 rethrow_exception(make_exception_ptr(0));
45 rethrow_exception(make_exception_ptr(runtime_error("test")));
46 } catch(exception
&e
) {
48 VERIFY( typeid(e
) == typeid(runtime_error
) );
50 VERIFY( strcmp(e
.what(), "test") == 0 );
62 ep
= current_exception();
65 rethrow_exception(ep
);
74 // Weave the exceptions in an attempt to confuse the machinery.
78 exception_ptr ep1
= current_exception();
82 exception_ptr ep2
= current_exception();
84 rethrow_exception(ep1
);
87 rethrow_exception(ep2
);
90 rethrow_exception(ep1
);
94 rethrow_exception(ep2
);
105 // libstdc++/64651 std::rethrow_exception not found by ADL
106 // This is not required to work but is a conforming extension.
108 rethrow_exception(std::make_exception_ptr(0));