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
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
..
algorithms [libcxx] Speeding up partition_point/lower_bound/upper_bound 7 years ago
atomics Revert "Add nonnull; use it for atomics" 8 years ago
containers [libcxx] Use custom allocator's `construct` in C++03 when available. 7 years ago
debug Fix PR35564 - std::list splice/erase incorrectly throw in debug mode. 8 years ago
depr Work around C++03 decltype limitations 7 years ago
diagnostics Mark [[nodiscard]] tests unsupported on GCC prior to 7.0 7 years ago
experimental Fix PR39749 - Headers containing just #error harm __has_include. 7 years ago
extensions Fix or move various non-standard tests. 10 years ago
fuzzing Add more fuzzing bits: partial_sort_copy, partition_copy, unique, unique_copy. No functional change to libc++; this is all test infastructure 8 years ago
input.output Set the buffer of an fstream to empty when the underlying file is closed. This 'fixes' PR#38052 - std::fstream still good after closing and updating content. 7 years ago
iterators Move old test into test/libcxx, and implement new version of test for ostreambuf_iterator::failed. Fixes PR#37245. Thanks to Billy O'Neill for the bug report. 8 years ago
language.support [libcxx] Remove outdated XFAILs for aligned deallocation 7 years ago
localization update XFAIL comments with more details 9 years ago
memory [Sema] Teach Clang that aligned allocation is not supported with macosx10.13 7 years ago
modules XFAIL Windows test failures under test/libcxx 9 years ago
numerics [libcxx] Improve accuracy of complex asinh and acosh 8 years ago
selftest Change a bunch of comments from C++1z to C++17. NFC 8 years ago
strings Add basic_string::__resize_default_init (from P1072) 7 years ago
thread Get tests compiling with -Wunused-local-typedef 7 years ago
type_traits Revert "Teach __libcpp_is_floating_point that __fp16 and _Float16 are" 7 years ago
utilities Fix PR40230 - std::pair may have padding on FreeBSD. 7 years ago
double_include.sh.cpp [libcxx] Remove dynarray 7 years ago
include_as_c.sh.cpp Allow the libc++ C header wrappers to be included when compiling C. 9 years ago
libcpp_alignof.pass.cpp Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`. 7 years ago
libcpp_version.pass.cpp Add test that _LIBCPP_VERSION matches __libcpp_version 9 years ago
min_max_macros.sh.cpp [libcxx] Remove dynarray 7 years ago