[libcxx-commits] [libcxx] [libc++] basic_ios<wchar_t> cannot store fill character WCHAR_MAX (PR #89305)
David Tenty via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 31 12:46:03 PDT 2024
================
@@ -590,7 +616,24 @@ protected:
private:
basic_ostream<char_type, traits_type>* __tie_;
- mutable int_type __fill_;
+
+#if defined(_AIX) || (defined(__MVS__) && defined(__64BIT__))
+// AIX and 64-bit MVS must use _OptionalFill for ABI backward compatibility.
+ using _FillType = _OptionalFill<_Traits>;
+#else
+#if defined(_WIN32)
+ static const bool _OptOutForABICompat = true;
+#else
+ static const bool _OptOutForABICompat = false;
+#endif
+
+ using _FillType = _If<
+ sizeof(char_type) >= sizeof(int_type) && !_OptOutForABICompat,
+ _OptionalFill<_Traits>,
+ _SentinelValueFill<_Traits>
+ >;
+#endif
----------------
daltenty wrote:
I feel like this platform ABI logic belongs in `include/__configuration/abi.h` (see Louis' recent refactor in https://github.com/llvm/llvm-project/commit/23e1ed65c2c3eb1f80f7eeb4897ec843492c5451), with flags like `_LIBCXX_IOS_MAY_USE_OPTIONAL_FILL` and `_LIBCXX_IOS_FORCE_OPTIONAL_FILL`
In ABI version 2, `_LIBCXX_IOS_MAY_USE_OPTIONAL_FILL` could simply be on, even on AIX and 64-bit MVS. In ABI version 1, we enable `_LIBCXX_IOS_FORCE_OPTIONAL_FILL` for AIX and 64-bit MVS and leave every thing else alone (that way we don't need to special case Windows like we do here)
Then this becomes:
```suggestion
#if defined(_LIBCXX_IOS_FORCE_OPTIONAL_FILL)
// AIX and 64-bit MVS must use _OptionalFill for ABI backward compatibility.
using _FillType = _OptionalFill<_Traits>;
#elif defined(_LIBCXX_IOS_MAY_USE_OPTIONAL_FILL)
using _FillType = _If<
sizeof(char_type) >= sizeof(int_type),
_OptionalFill<_Traits>,
_SentinelValueFill<_Traits>
>;
#else
using _FillType = _SentinelValueFill<_Traits>;
#endif
```
https://github.com/llvm/llvm-project/pull/89305
More information about the libcxx-commits
mailing list