Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -387,6 +387,10 @@ # Prevent libc++abi from having library dependencies on libc++ add_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE) +# Bring back `std::unexpected`, which is removed in C++17, to support +# pre-C++17. +add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) + if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() Index: src/cxa_exception.cpp =================================================================== --- src/cxa_exception.cpp +++ src/cxa_exception.cpp @@ -11,8 +11,6 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS - #include "cxxabi.h" #include // for std::terminate Index: test/test_exception_storage.pass.cpp =================================================================== --- test/test_exception_storage.pass.cpp +++ test/test_exception_storage.pass.cpp @@ -7,11 +7,6 @@ // //===----------------------------------------------------------------------===// -// FIXME: cxa_exception.hpp directly references `std::unexpected` and friends. -// This breaks this test when compiled in C++17. For now fix this by manually -// re-enabling the STL functions. -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS - #include #include #include