@@ -28,8 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28
28
// understand how it works). //
29
29
// ================================================================================================================== //
30
30
31
- // The first member is aligned to the alignment of the second member to force padding in front of the compressed pair
32
- // in case there are members before it.
31
+ // On GCC, the first member is aligned to the alignment of the second member to force padding in front of the compressed
32
+ // pair in case there are members before it.
33
33
//
34
34
// For example:
35
35
// (assuming x86-64 linux)
@@ -53,6 +53,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
53
53
// Furthermore, that alignment must be the same as what was used in the old __compressed_pair layout, so we must
54
54
// handle reference types specially since alignof(T&) == alignof(T).
55
55
// See https://llvm.org/PR118559.
56
+ //
57
+ // On Clang, this is unnecessary, since we use anonymous structs instead, which automatically handle the alignment
58
+ // correctly.
56
59
57
60
#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
58
61
@@ -104,18 +107,15 @@ class __compressed_pair_padding<_ToPad, true> {};
104
107
# else
105
108
# define _LIBCPP_COMPRESSED_PAIR (T1, Initializer1, T2, Initializer2 ) \
106
109
struct { \
107
- _LIBCPP_NO_UNIQUE_ADDRESS \
108
- __attribute__ ((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \
110
+ _LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1; \
109
111
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3 (__padding1_, __LINE__, _); \
110
112
_LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
111
113
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3 (__padding2_, __LINE__, _); \
112
114
}
113
115
114
116
# define _LIBCPP_COMPRESSED_TRIPLE (T1, Initializer1, T2, Initializer2, T3, Initializer3 ) \
115
117
struct { \
116
- _LIBCPP_NO_UNIQUE_ADDRESS \
117
- __attribute__ ((__aligned__(::std::__compressed_pair_alignment<T2>), \
118
- __aligned__ (::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \
118
+ _LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1; \
119
119
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3 (__padding1_, __LINE__, _); \
120
120
_LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
121
121
_LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3 (__padding2_, __LINE__, _); \
0 commit comments