diff --git a/libcxx/include/__configuration/abi.h b/libcxx/include/__configuration/abi.h index 17aceb042f524a..b83e7bf97a5595 100644 --- a/libcxx/include/__configuration/abi.h +++ b/libcxx/include/__configuration/abi.h @@ -91,6 +91,15 @@ # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW // Dont' add an inline namespace for `std::filesystem` # define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE +// libcxx std::basic_ios uses WEOF to indicate that the fill value is +// uninitialized. However, on platforms where the size of char_type is +// equal to or greater than the size of int_type, +// std::char_traits::eq_int_type() cannot distinguish between WEOF +// and WCHAR_MAX. Helper class _OptionalFill is used for targets where a +// variable is needed to indicate whether the fill value has been initialized. +// Existing targets where this would break ABI compatibility can choose to keep +// the existing ABI by undefining macro _LIBCXX_IOS_MAY_USE_OPTIONAL_FILL. +# define _LIBCXX_IOS_MAY_USE_OPTIONAL_FILL #elif _LIBCPP_ABI_VERSION == 1 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) // Enable compiling copies of now inline methods into the dylib to support @@ -108,6 +117,10 @@ # if defined(__FreeBSD__) && __FreeBSD__ < 14 # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR # endif +// AIX and 64-bit MVS must use _OptionalFill for ABI backward compatibility. +# if defined(_AIX) || (defined(__MVS__) && defined(__64BIT__)) +# define _LIBCXX_IOS_FORCE_OPTIONAL_FILL +# endif #endif // We had some bugs where we use [[no_unique_address]] together with construct_at, diff --git a/libcxx/include/ios b/libcxx/include/ios index 3961504f62b39c..d056b1ccb8681d 100644 --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -617,21 +617,16 @@ protected: private: basic_ostream* __tie_; -#if defined(_AIX) || (defined(__MVS__) && defined(__64BIT__)) -// AIX and 64-bit MVS must use _OptionalFill for ABI backward compatibility. +#if defined(_LIBCXX_IOS_FORCE_OPTIONAL_FILL) using _FillType = _OptionalFill<_Traits>; -#else -#if defined(_WIN32) - static const bool _OptOutForABICompat = true; -#else - static const bool _OptOutForABICompat = false; -#endif - +#elif defined(_LIBCXX_IOS_MAY_USE_OPTIONAL_FILL) using _FillType = _If< - sizeof(char_type) >= sizeof(int_type) && !_OptOutForABICompat, + sizeof(char_type) >= sizeof(int_type), _OptionalFill<_Traits>, _SentinelValueFill<_Traits> >; +#else + using _FillType = _SentinelValueFill<_Traits>; #endif mutable _FillType __fill_; };