[libcxx-commits] [libcxx] [libc++] Fix unintended ABI break in associative containers with reference comparators (PR #118685)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 4 11:18:50 PST 2024
================
@@ -50,9 +50,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// member1 - offset: 0, size: 4
// member2 - offset: 4, size: 4
// member3 - offset: 8, size: 8
+//
+// Furthermore, that alignment must be the same as what was used in the old __compressed_pair layout, so we must
+// handle reference types specially since alignof(T&) == alignof(T). See https://github.com/llvm/llvm-project/issues/118559.
#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
+template <class _Tp>
+struct __compressed_pair_alignment : integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
+
+template <class _Tp>
+struct __compressed_pair_alignment<_Tp&> : integral_constant<size_t, _LIBCPP_ALIGNOF(void*)> {};
----------------
philnik777 wrote:
```suggestion
template <class _Tp>
inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp);
template <class _Tp>
inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(_Tp*);
```
https://github.com/llvm/llvm-project/pull/118685
More information about the libcxx-commits
mailing list