| 1 | // { dg-do run { target c++17 } } |
| 2 | // PR libstdc++/105258 std::get_temporary_buffer() does not respect alignment |
| 3 | |
| 4 | #include <algorithm> |
| 5 | #include <cstdint> |
| 6 | #include <testsuite_hooks.h> |
| 7 | |
| 8 | struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) Overaligned |
| 9 | { |
| 10 | ~Overaligned() |
| 11 | { |
| 12 | auto alignment = reinterpret_cast<std::uintptr_t>(this); |
| 13 | VERIFY( (alignment % alignof(Overaligned)) == 0 ); |
| 14 | } |
| 15 | |
| 16 | bool operator<(const Overaligned&) const { return false; } |
| 17 | }; |
| 18 | |
| 19 | void |
| 20 | test_pr105258() |
| 21 | { |
| 22 | Overaligned o[2]; |
| 23 | std::stable_sort(o, o+2); |
| 24 | } |
| 25 | |
| 26 | int main() |
| 27 | { |
| 28 | test_pr105258(); |
| 29 | } |