https://gcc.gnu.org/g:c48ee25ca1666a7baafd6e31c13b2489312b891c
commit r17-6064-gc48ee25ca1666a7baafd6e31c13b2489312b891c Author: Jonathan Wakely <[email protected]> Date: Mon Nov 9 09:51:02 2026 +0000 libstdc++: Declare std::exception_ptr as type alias The standard specifies this in [propagation]: using exception_ptr = _unspecified_; We instead define it with a using-declaration that pulls std::__exception_ptr::exception_ptr into namespace std. The difference is observable using reflection, as in the new test. This changes the declaration of std::exception_ptr to be a typedef-declaration instead of a using-declaration. That's equivalent to an alias-declaration for the purposes of reflection, and preserves our support for std::exception_ptr as an extension in C++98 mode. libstdc++-v3/ChangeLog: * libsupc++/exception_ptr.h (exception_ptr): Declare as type alias not via using-declaration. * testsuite/18_support/exception_ptr/meta.cc: New test. Reviewed-by: Tomasz KamiĆski <[email protected]> Diff: --- libstdc++-v3/libsupc++/exception_ptr.h | 2 +- libstdc++-v3/testsuite/18_support/exception_ptr/meta.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index 81efe49be1fc..ab34f4e634fa 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -67,7 +67,7 @@ namespace std _GLIBCXX_VISIBILITY(default) class exception_ptr; } - using __exception_ptr::exception_ptr; + typedef __exception_ptr::exception_ptr exception_ptr; /** Obtain an exception_ptr to the currently handled exception. * diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/meta.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/meta.cc new file mode 100644 index 000000000000..be228c20c3d0 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/exception_ptr/meta.cc @@ -0,0 +1,15 @@ +// { dg-options "-freflection" } +// { dg-do compile { target c++26 } } +// { dg-require-effective-target cxx11_abi } + +#include <exception> +#include <meta> + +consteval bool test_exception_ptr_is_type_alias() +{ + auto exptr = ^^std::exception_ptr; + return std::meta::is_type_alias(exptr) + && std::meta::dealias(exptr) == ^^decltype(std::current_exception()); +} + +static_assert( test_exception_ptr_is_type_alias() );
