@@ -50,9 +50,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
50
50
// member1 - offset: 0, size: 4
51
51
// member2 - offset: 4, size: 4
52
52
// member3 - offset: 8, size: 8
53
+ //
54
+ // Furthermore, that alignment must be the same as what was used in the old __compressed_pair layout, so we must
55
+ // handle reference types specially since alignof(T&) == alignof(T).
56
+ // See https://github.com/llvm/llvm-project/issues/118559.
53
57
54
58
#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
55
59
60
+ template <class _Tp >
61
+ inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp);
62
+
63
+ template <class _Tp >
64
+ inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void *);
65
+
56
66
template <class _ToPad ,
57
67
bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) ||
58
68
is_reference<_ToPad>::value || sizeof (_ToPad) == __datasizeof_v<_ToPad>)>
@@ -64,14 +74,15 @@ template <class _ToPad>
64
74
class __compressed_pair_padding <_ToPad, true > {};
65
75
66
76
# define _LIBCPP_COMPRESSED_PAIR (T1, Initializer1, T2, Initializer2 ) \
67
- _LIBCPP_NO_UNIQUE_ADDRESS __attribute__ ((__aligned__(_LIBCPP_ALIGNOF(T2 )))) T1 Initializer1; \
77
+ _LIBCPP_NO_UNIQUE_ADDRESS __attribute__ ((__aligned__(::std::__compressed_pair_alignment<T2> ))) T1 Initializer1; \
68
78
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3 (__padding1_, __LINE__, _); \
69
79
_LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
70
80
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3 (__padding2_, __LINE__, _)
71
81
72
82
# define _LIBCPP_COMPRESSED_TRIPLE (T1, Initializer1, T2, Initializer2, T3, Initializer3 ) \
73
83
_LIBCPP_NO_UNIQUE_ADDRESS \
74
- __attribute__ ((__aligned__(_LIBCPP_ALIGNOF(T2)), __aligned__(_LIBCPP_ALIGNOF(T3)))) T1 Initializer1; \
84
+ __attribute__ ((__aligned__(::std::__compressed_pair_alignment<T2>), \
85
+ __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \
75
86
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3 (__padding1_, __LINE__, _); \
76
87
_LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
77
88
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3 (__padding2_, __LINE__, _); \
0 commit comments