This is an archive of the discontinued LLVM Phabricator instance.

Fix std::pair on FreeBSD
ClosedPublic

Authored by EricWF on Oct 7 2016, 7:29 PM.

Details

Summary

FreeBSD ships an old ABI for std::pair which requires that it have non-trivial copy/move constructors. Currently the non-trivial copy/move is achieved by providing explicit definitions of the constructors. This is problematic because it means the constructors don't SFINAE properly. In order to SFINAE copy/move constructors they have to be explicitly defaulted and hense non-trivial.

This patch attempts to provide SFINAE'ing copy/move constructors for std::pair while still making them non-trivial. It does this by adding a base class with a non-trivial copy constructor and then allowing pair's constructors to be generated by the compiler. This also allows the constructors to be constexpr.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 74009.Oct 7 2016, 7:29 PM
EricWF retitled this revision from to Fix std::pair on FreeBSD.
EricWF updated this object.
EricWF added reviewers: emaste, dim, theraven, rsmith.
EricWF added a subscriber: cfe-commits.
dim accepted this revision.Oct 10 2016, 12:44 PM
dim edited edge metadata.

Yes, this looks good to me. For trunk r283783, this brought the number of unexpected failures down from 61 to 41. Tests fixed by this change:

libc++ :: std/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp
libc++ :: std/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
libc++ :: std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
libc++ :: std/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
libc++ :: std/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp
libc++ :: std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
libc++ :: std/experimental/string.view/string.view.find/find_pointer_size.pass.cpp
libc++ :: std/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp
libc++ :: std/experimental/string.view/string.view.find/find_string_view_size.pass.cpp
libc++ :: std/strings/string.view/string.view.find/find_pointer_size.pass.cpp
libc++ :: std/strings/string.view/string.view.find/find_pointer_size_size.pass.cpp
libc++ :: std/strings/string.view/string.view.find/find_string_view_size.pass.cpp
libc++ :: std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp
libc++ :: std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
libc++ :: std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
libc++ :: std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
libc++ :: std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp
libc++ :: std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
libc++ :: std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp
libc++ :: std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
This revision is now accepted and ready to land.Oct 10 2016, 12:44 PM
EricWF closed this revision.Oct 11 2016, 2:31 PM