You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
libcxx_old/test/libcxx/utilities/utility/pairs/pairs.pair
Eric Fiselier 6840e5476e Fix PR40230 - std::pair may have padding on FreeBSD.
Summary:
FreeBSD ships a very old and deprecated ABI for std::pair where the copy and move constructors are not allowed to be trivial. D25389 change how this was implemented by introducing a non-trivial base class. This patch, introduced in October 2016, introduced an ABI bug that caused nested `std::pair` instantiations to have padding. For example:

```
using PairT = std::pair< std::pair<char, char>, char >;
static_assert(offsetof(PairT, first) == 0, "First member should exist at offset zero"); // Fails on FreeBSD!
```

The bug occurs because the base class for the first element (the nested pair) cannot be put at offset zero because the top-level pair already has the same base class laid out there.

This patch fixes that ABI bug by templating the dummy base class on the same parameters as the pair.

Technically this fix is an ABI break for users who depend on the "broken" ABI introduced in 2016. I'm putting this up for review so that the FreeBSD maintainers can sign off on fixing the ABI by breaking the ABI.
Another option, since we have to "break" the ABI to fix it, would be to move FreeBSD off the deprecated non-trivial pair ABI instead.

Also see:

* https://llvm.org/PR40230
* https://reviews.llvm.org/D21329



Reviewers: rsmith, dim, emaste

Reviewed By: rsmith

Subscribers: mclow.lists, krytarowski, christof, ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D56357

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@351290 91177308-0d34-0410-b5e6-96231b3b80d8
7 years ago
..
U_V.pass.cpp [pair] Mark constructors as conditionally noexcept 7 years ago
assign_tuple_like.pass.cpp Move libc++ pair/tuple assign test to libcxx/ test directory. 8 years ago
const_first_const_second.pass.cpp [pair] Mark constructors as conditionally noexcept 7 years ago
const_pair_U_V.pass.cpp [pair] Mark constructors as conditionally noexcept 7 years ago
default.pass.cpp [libcxx] Fix test failure on GCC 4.9 7 years ago
non_trivial_copy_move_ABI.pass.cpp Fix PR40230 - std::pair may have padding on FreeBSD. 7 years ago
pair.tuple_element.fail.cpp Fix static assert diagnostic checks in i386 7 years ago
piecewise.pass.cpp [pair] Mark constructors as conditionally noexcept 7 years ago
rv_pair_U_V.pass.cpp [pair] Mark constructors as conditionally noexcept 7 years ago
trivial_copy_move_ABI.pass.cpp Fix PR40230 - std::pair may have padding on FreeBSD. 7 years ago