Index: libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp =================================================================== --- libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp +++ libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp @@ -14,6 +14,7 @@ // #include +#include #include #include "test_macros.h" @@ -81,25 +82,40 @@ assert(d0 < d1); // sanity checking assert(d1 < d2); // sanity checking -// Since there's nothing in between, the midpoint has to be one or the other - T res; - res = std::midpoint(d0, d1); - assert(res == d0 || res == d1); - assert(d0 <= res); - assert(res <= d1); - res = std::midpoint(d1, d0); - assert(res == d0 || res == d1); - assert(d0 <= res); - assert(res <= d1); - - res = std::midpoint(d1, d2); - assert(res == d1 || res == d2); - assert(d1 <= res); - assert(res <= d2); - res = std::midpoint(d2, d1); - assert(res == d1 || res == d2); - assert(d1 <= res); - assert(res <= d2); +#if __PPC__ && __LONG_DOUBLE_128__ && !__LONG_DOUBLE_IEEE128__ + // For 128 bit long double implemented as 2 doubles on PowerPC, + // nextafterl() of libm gives imprecise results which fails the + // midpoint() tests below. So skip the test for this case. + bool skipTest = sizeof(T) == 16 ? true : false; +#else + bool skipTest = false; +#endif + if (!skipTest) { + // Since there's nothing in between, the midpoint has to be one or + // the other. + T res; + res = std::midpoint(d0, d1); + assert(res == d0 || res == d1); + assert(d0 <= res); + assert(res <= d1); + res = std::midpoint(d1, d0); + assert(res == d0 || res == d1); + assert(d0 <= res); + assert(res <= d1); + + res = std::midpoint(d1, d2); + assert(res == d1 || res == d2); + assert(d1 <= res); + assert(res <= d2); + res = std::midpoint(d2, d1); + assert(res == d1 || res == d2); + assert(d1 <= res); + assert(res <= d2); + } else { + std::cerr + << "Skipped checking midpoint of adjacent values for PPC double-double." + << "\n"; + } }