[libcxx-commits] [libcxx] [libc++] basic_ios<wchar_t> cannot store fill character WCHAR_MAX (PR #89305)

Sean Perry via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 19 07:29:35 PDT 2024


================
@@ -521,6 +522,31 @@ inline _LIBCPP_HIDE_FROM_ABI void ios_base::exceptions(iostate __iostate) {
   clear(__rdstate_);
 }
 
+template <class _Traits>
+// Attribute 'packed' is used to keep the layout compatible with the previous
----------------
perry-ca wrote:

Can you expand this comment to explain this doesn't give 100% compat.  It will eliminate the tail padding and keep the member after this one in the right offset.  However, being packed the alignment of this struct will be 1 instead of the alignment of int_type.  If this struct was added as a member where the offset wasn't already a multiple of the alignment of int_type then the offset would not be preserved.

I don't think you can take the int_type/bool pair and put them in a struct that will preserve the size and alignment of the original pair.  You can either get the alignment correct or the size correct and not both.

https://github.com/llvm/llvm-project/pull/89305


More information about the libcxx-commits mailing list