diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -70,6 +70,15 @@ from the Standard since it was never used, the proper specialization to use instead is ``template struct formatter``. +- Libc++ used to provide some C++11 tag type global variables in C++03 as an extension, which are removed in + this release. Those variables were ``std::allocator_arg``, ``std::defer_lock``, ``std::try_to_lock``, + ``std::adopt_lock``, and ``std::piecewise_construct``. Note that the types associated to those variables are + still provided in C++03 as an extension (e.g. ``std::piecewise_construct_t``). Providing those variables in + C++03 mode made it impossible to define them properly -- C++11 mandated that they be ``constexpr`` variables, + which is impossible in C++03 mode. Furthermore, C++17 mandated that they be ``inline constexpr`` variables, + which led to ODR violations when mixed with the C++03 definition. Cleaning this up is required for libc++ to + make progress on support for C++20 modules. + Upcoming Deprecations and Removals ---------------------------------- diff --git a/libcxx/include/__memory/allocator_arg_t.h b/libcxx/include/__memory/allocator_arg_t.h --- a/libcxx/include/__memory/allocator_arg_t.h +++ b/libcxx/include/__memory/allocator_arg_t.h @@ -25,9 +25,9 @@ struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; }; -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) +#if defined(_LIBCPP_BUILDING_LIBRARY) extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; -#else +#elif !defined(_LIBCPP_CXX03_LANG) /* inline */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); #endif diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base --- a/libcxx/include/__mutex_base +++ b/libcxx/include/__mutex_base @@ -64,19 +64,15 @@ struct _LIBCPP_TYPE_VIS try_to_lock_t { explicit try_to_lock_t() = default; }; struct _LIBCPP_TYPE_VIS adopt_lock_t { explicit adopt_lock_t() = default; }; -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) - -extern _LIBCPP_EXPORTED_FROM_ABI const defer_lock_t defer_lock; +# if defined(_LIBCPP_BUILDING_LIBRARY) +extern _LIBCPP_EXPORTED_FROM_ABI const defer_lock_t defer_lock; extern _LIBCPP_EXPORTED_FROM_ABI const try_to_lock_t try_to_lock; -extern _LIBCPP_EXPORTED_FROM_ABI const adopt_lock_t adopt_lock; - -#else - -/* inline */ constexpr defer_lock_t defer_lock = defer_lock_t(); +extern _LIBCPP_EXPORTED_FROM_ABI const adopt_lock_t adopt_lock; +# elif !defined(_LIBCPP_CXX03_LANG) +/* inline */ constexpr defer_lock_t defer_lock = defer_lock_t(); /* inline */ constexpr try_to_lock_t try_to_lock = try_to_lock_t(); -/* inline */ constexpr adopt_lock_t adopt_lock = adopt_lock_t(); - -#endif +/* inline */ constexpr adopt_lock_t adopt_lock = adopt_lock_t(); +# endif template class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) diff --git a/libcxx/include/__utility/piecewise_construct.h b/libcxx/include/__utility/piecewise_construct.h --- a/libcxx/include/__utility/piecewise_construct.h +++ b/libcxx/include/__utility/piecewise_construct.h @@ -18,9 +18,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { explicit piecewise_construct_t() = default; }; -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) -extern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); -#else + +#if defined(_LIBCPP_BUILDING_LIBRARY) +extern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct; +#elif !defined(_LIBCPP_CXX03_LANG) /* inline */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); #endif