int main( void )
{
- std::set_unexpected( []{ throw 0; } );
+ std::set_unexpected( []{ throw 0; } ); // { dg-warning "deprecated" }
try
{
[]() throw( int ) { throw nullptr; }(); // { dg-warning "deprecated" }
int main()
{
- std::set_unexpected (my_unexpected);
+ std::set_unexpected (my_unexpected); // { dg-warning "deprecated" }
std::set_terminate (my_terminate);
f();
return 1;
int main()
{
- std::set_unexpected (my_unexpected);
+ std::set_unexpected (my_unexpected); // { dg-warning "deprecated" }
f();
return 1;
}
int main()
{
- std::set_unexpected (handle_unexpected);
+ std::set_unexpected (handle_unexpected); // { dg-warning "deprecated" "" { target c++11 } }
doit ();
abort ();
}
int main ()
{
- std::set_unexpected (handle_unexpected);
+ std::set_unexpected (handle_unexpected); // { dg-warning "deprecated" "" { target { c++11 } } }
try
{
int main ()
{
std::set_terminate (my_term);
- std::set_unexpected (my_unexp);
+ std::set_unexpected (my_unexp); // { dg-warning "deprecated" "" { target c++11 } }
try
{
int main ()
{
std::set_terminate (my_term);
- std::set_unexpected (my_unexp);
+ std::set_unexpected (my_unexp); // { dg-warning "deprecated" "" { target c++11 } }
try
{
int main ()
{
std::set_terminate (my_term);
- std::set_unexpected (my_unexp);
+ std::set_unexpected (my_unexp); // { dg-warning "deprecated" "" { target c++11 } }
try
{
int main ()
{
std::set_terminate (my_term);
- std::set_unexpected (my_unexp);
+ std::set_unexpected (my_unexp); // { dg-warning "deprecated" "" { target c++11 } }
try
{
void foo() throw (int) { throw "Hi"; } // { dg-warning "deprecated" "" { target c++11 } }
int main() {
- std::set_unexpected (my_unexpected);
+ std::set_unexpected (my_unexpected); // { dg-warning "deprecated" "" { target c++11 } }
try {
foo();
} catch (int i) {
void foo() throw () { throw "Hi"; }
int main() {
- std::set_unexpected (my_unexpected);
+ std::set_unexpected (my_unexpected); // { dg-warning "deprecated" "" { target c++11 } }
foo();
return 1;
}
int
main() {
- std::set_unexpected (my_unexpected);
+ std::set_unexpected (my_unexpected); // { dg-warning "deprecated" "" { target c++11 } }
try {
foo(1);
} catch (int i) {
int
main() {
- std::set_unexpected (my_unexpected);
+ std::set_unexpected (my_unexpected); // { dg-warning "deprecated" "" { target c++11 } }
try {
foo(1);
} catch (int i) {
The <code class="function">std::random_shuffle</code> algorithms are deprecated
for C++14 and later. The C++11 <code class="function">std::shuffle</code> algorithm
can be used instead.
+</p><p>
+The <code class="function">std::unexpected</code> function and related typedef and
+accessors for the unexpected handler are deprecated for C++11 and later.
+Dynamic exception specifications should be replaced with <code class="code">noexcept</code>.
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="abi.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix_porting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="backwards.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ABI Policy and Guidelines </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Backwards Compatibility</td></tr></table></div></body></html>
\ No newline at end of file
can be used instead.
</para>
+<para>
+The <function>std::unexpected</function> function and related typedef and
+accessors for the unexpected handler are deprecated for C++11 and later.
+Dynamic exception specifications should be replaced with <code>noexcept</code>.
+</para>
+
</section>
</section>
std::terminate ();
else if (handler_switch_value < 0)
{
- __try
- { std::unexpected (); }
- __catch(...)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ __try
+ { std::unexpected (); }
+ __catch(...)
{ std::terminate (); }
+#pragma GCC diagnostic pop
}
}
else
dep->primaryException = obj;
__gnu_cxx::__eh_atomic_inc (&eh->referenceCount);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
dep->unexpectedHandler = get_unexpected ();
+#pragma GCC diagnostic pop
dep->terminateHandler = get_terminate ();
__GXX_INIT_DEPENDENT_EXCEPTION_CLASS(dep->unwindHeader.exception_class);
dep->unwindHeader.exception_cleanup = __gxx_dependent_exception_cleanup;
__cxxabiv1::__terminate (get_terminate ());
}
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
void
__cxxabiv1::__unexpected (std::unexpected_handler handler)
{
header->referenceCount = 0;
header->exc.exceptionType = tinfo;
header->exc.exceptionDestructor = dest;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
header->exc.unexpectedHandler = std::get_unexpected ();
+#pragma GCC diagnostic pop
header->exc.terminateHandler = std::get_terminate ();
__GXX_INIT_PRIMARY_EXCEPTION_CLASS(header->exc.unwindHeader.exception_class);
header->exc.unwindHeader.exception_cleanup = __gxx_exception_cleanup;
/// If you write a replacement %terminate handler, it must be of this type.
typedef void (*terminate_handler) ();
- /// If you write a replacement %unexpected handler, it must be of this type.
- typedef void (*unexpected_handler) ();
-
/// Takes a new handler function as an argument, returns the old function.
terminate_handler set_terminate(terminate_handler) _GLIBCXX_USE_NOEXCEPT;
* abandoned for any reason. It can also be called by the user. */
void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__));
- /// Takes a new handler function as an argument, returns the old function.
+#if __cplusplus < 201703L || _GLIBCXX_USE_DEPRECATED
+ /// If you write a replacement %unexpected handler, it must be of this type.
+ typedef void (*_GLIBCXX11_DEPRECATED unexpected_handler) ();
+
+ /** Takes a new handler function as an argument, returns the old function.
+ *
+ * @deprecated Removed from the C++ standard in C++17
+ */
+ _GLIBCXX11_DEPRECATED
unexpected_handler set_unexpected(unexpected_handler) _GLIBCXX_USE_NOEXCEPT;
#if __cplusplus >= 201103L
- /// Return the current unexpected handler.
+ /** Return the current unexpected handler.
+ *
+ * @since C++11
+ * @deprecated Removed from the C++ standard in C++17
+ */
+ _GLIBCXX11_DEPRECATED
unexpected_handler get_unexpected() noexcept;
#endif
/** The runtime will call this function if an %exception is thrown which
- * violates the function's %exception specification. */
+ * violates the function's %exception specification.
+ *
+ * @deprecated Removed from the C++ standard in C++17
+ */
+ _GLIBCXX11_DEPRECATED
void unexpected() __attribute__ ((__noreturn__));
+#endif
/** [18.6.4]/1: 'Returns true after completing evaluation of a
* throw-expression until either completing initialization of the
// The C++ standard has entertaining rules wrt calling set_terminate
// and set_unexpected in the middle of the exception cleanup process.
- std::unexpected_handler unexpectedHandler;
+ std::terminate_handler unexpectedHandler;
std::terminate_handler terminateHandler;
// The caught exception stack threads through here.
// The C++ standard has entertaining rules wrt calling set_terminate
// and set_unexpected in the middle of the exception cleanup process.
- std::unexpected_handler unexpectedHandler;
+ std::terminate_handler unexpectedHandler;
std::terminate_handler terminateHandler;
// The caught exception stack threads through here.
// so inconsiderate as to return.
extern void __terminate(std::terminate_handler) throw ()
__attribute__((__noreturn__));
-extern void __unexpected(std::unexpected_handler)
+extern void __unexpected(std::terminate_handler)
__attribute__((__noreturn__));
// The current installed user handlers.
extern std::terminate_handler __terminate_handler;
-extern std::unexpected_handler __unexpected_handler;
+extern std::terminate_handler __unexpected_handler;
// These are explicitly GNU C++ specific.
+// { dg-options "-Wno-deprecated-declarations" }
// { dg-do run { target { c++11_only || c++14_only } } }
// Copyright (C) 2014-2021 Free Software Foundation, Inc.
class bad_exception;
typedef void (*unexpected_handler)();
- unexpected_handler set_unexpected(unexpected_handler f ) throw();
+ unexpected_handler set_unexpected(unexpected_handler f ) throw(); // { dg-warning "deprecated" { target c++11 } }
unexpected_handler get_unexpected() noexcept;
void unexpected();
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-std=gnu++11" }
+// { dg-options "-std=gnu++11 -Wno-deprecated-declarations" }
// { dg-do run { target { c++11_only || c++14_only } } }
#include <exception>
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+// { dg-options "-Wno-deprecated-declarations" }
// { dg-do run { target c++11 } }
// D.11 Violating exception-specifications