diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_U_V_move.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_U_V_move.pass.cpp index 3b2d093eb34d4..8ba9b5696eff1 100644 --- a/libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_U_V_move.pass.cpp +++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_U_V_move.pass.cpp @@ -121,7 +121,28 @@ int main(int, char**) test_pair_rv(); test_pair_rv(); - test_pair_rv(); + /* For ExplicitTypes::CopyOnly, two of the viable candidates for initializing from a non-const xvalue are: + * pair(const pair&); // (defaulted copy constructor) + * template explicit pair(const pair&&); [U1 = ExplicitTypes::CopyOnly, U2 = int] + * + * This results in diverging behavior for test_convertible which uses copy-list-initialization. + * Prior to CWG2137, this would have selected the first (non-explicit) ctor as explicit ctors + * would not be considered. Afterwards, it should select the second since it is a better match, + * and then failed because it is explicit. + * + * This may change with future defect reports, and some compilers only have partial support + * for CWG2137, so use std::is_convertible directly to avoid a copy-list-initialization + */ + { + using P1 = std::pair; + using P2 = std::pair; + using UP1 = std::pair&&; + using UP2 = std::pair&&; + static_assert(std::is_constructible::value, ""); + static_assert(std::is_convertible::value, ""); + static_assert(std::is_constructible::value, ""); + static_assert(std::is_convertible::value, ""); + } test_pair_rv(); test_pair_rv();