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
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
..
any Add missing REQUIRES for C++14 9 years ago
function.objects [libcxx] [test] Make files consistently end with newlines, NFC. 8 years ago
memory Fix failing -verify tests due to change in Clangs static_assert message. 8 years ago
meta Cleanup _LIBCPP_HAS_NO_<c++11-feature> in support headers and final tests 9 years ago
optional [libcxx] Reorganize tests since the application of P0602R4 7 years ago
ratio Move remaining _LIBCPP_VERSION tests into test/libcxx 10 years ago
template.bitset Fix or move tests with non-standard assumptions 9 years ago
time Move remaining _LIBCPP_VERSION tests into test/libcxx 10 years ago
tuple Fix diagnostic test to tolerate Clang diagnosing it as well. 7 years ago
type.index Move remaining _LIBCPP_VERSION tests into test/libcxx 10 years ago
utility Fix PR40230 - std::pair may have padding on FreeBSD. 7 years ago
variant Work around GCC 9.0 regression 7 years ago