Skip to content

Commit 53a529f

Browse files
committed
Add test for preferred alignment
1 parent 09b00bb commit 53a529f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/assert.subscript.pass.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,20 @@ struct alignas(128) OveralignedWithCookie {
167167
char padding[Size];
168168
};
169169

170+
// These types have a different ABI alignment (alignof) and preferred alignment (__alignof) on some platforms.
171+
// Make sure things work with these types because array cookies can be sensitive to preferred alignment on some
172+
// platforms.
173+
struct WithCookiePreferredAlignment {
174+
WithCookiePreferredAlignment() = default;
175+
WithCookiePreferredAlignment(WithCookiePreferredAlignment const&) {}
176+
WithCookiePreferredAlignment& operator=(WithCookiePreferredAlignment const&) { return *this; }
177+
~WithCookiePreferredAlignment() {}
178+
long double data;
179+
};
180+
struct NoCookiePreferredAlignment {
181+
long double data;
182+
};
183+
170184
int main(int, char**) {
171185
test<WithCookie<1>, NoCookie<1>>();
172186
test<WithCookie<2>, NoCookie<2>>();
@@ -187,6 +201,7 @@ int main(int, char**) {
187201
test<OveralignedWithCookie<256>, OveralignedNoCookie<256>>();
188202

189203
test<std::string, int>();
204+
test<WithCookiePreferredAlignment, NoCookiePreferredAlignment>();
190205

191206
return 0;
192207
}

0 commit comments

Comments
 (0)