Index: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp +++ test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp @@ -16,8 +16,9 @@ #include #include +#include #include // for rand() -#include +#include constexpr struct { int x; @@ -36,21 +37,29 @@ template -constexpr bool test0(Input1 in1, Input2 in2, Output out) +constexpr bool test0(int in1, int in2, int out) { - static_assert((std::is_same::value), "" ); - static_assert((std::is_same::value), "" ); - return out == std::gcd(in1, in2) ? true : (std::abort(), false); + static_assert(std::is_same(0), static_cast(0)))>::value, ""); + static_assert(std::is_same(0), static_cast(0)))>::value, ""); + const bool result = static_cast>(out) == + std::gcd(static_cast(in1), static_cast(in2)); + if (!result) { + std::abort(); + } + + return result; } template constexpr bool do_test(int = 0) { - using S1 = typename std::make_signed::type; - using S2 = typename std::make_signed::type; - using U1 = typename std::make_unsigned::type; - using U2 = typename std::make_unsigned::type; + using S1 = std::make_signed_t; + using S2 = std::make_signed_t; + using U1 = std::make_unsigned_t; + using U2 = std::make_unsigned_t; bool accumulate = true; for (auto TC : Cases) { { // Test with two signed types @@ -103,15 +112,15 @@ assert(do_test(non_cce)); assert(do_test(non_cce)); - static_assert(do_test< int8_t>(), ""); - static_assert(do_test(), ""); - static_assert(do_test(), ""); - static_assert(do_test(), ""); + static_assert(do_test(), ""); + static_assert(do_test(), ""); + static_assert(do_test(), ""); + static_assert(do_test(), ""); - assert(do_test< int8_t>(non_cce)); - assert(do_test(non_cce)); - assert(do_test(non_cce)); - assert(do_test(non_cce)); + assert(do_test(non_cce)); + assert(do_test(non_cce)); + assert(do_test(non_cce)); + assert(do_test(non_cce)); static_assert(do_test(), ""); static_assert(do_test(), ""); @@ -133,8 +142,8 @@ // LWG#2837 { - auto res = std::gcd((int64_t)1234, (int32_t)-2147483648); - static_assert( std::is_same::type>::value, ""); + auto res = std::gcd(static_cast(1234), INT32_MIN); + static_assert(std::is_same::value, ""); assert(res == 2); } } Index: test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp +++ test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp @@ -11,12 +11,13 @@ // // template -// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n) +// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n) #include #include +#include #include -#include +#include constexpr struct { int x; @@ -34,21 +35,29 @@ }; template -constexpr bool test0(Input1 in1, Input2 in2, Output out) +constexpr bool test0(int in1, int in2, int out) { - static_assert((std::is_same::value), "" ); - static_assert((std::is_same::value), "" ); - return out == std::lcm(in1, in2) ? true : (std::abort(), false); + static_assert(std::is_same(0), static_cast(0)))>::value, ""); + static_assert(std::is_same(0), static_cast(0)))>::value, ""); + const bool result = static_cast>(out) == + std::lcm(static_cast(in1), static_cast(in2)); + if (!result) { + std::abort(); + } + + return result; } template constexpr bool do_test(int = 0) { - using S1 = typename std::make_signed::type; - using S2 = typename std::make_signed::type; - using U1 = typename std::make_unsigned::type; - using U2 = typename std::make_unsigned::type; + using S1 = std::make_signed_t; + using S2 = std::make_signed_t; + using U1 = std::make_unsigned_t; + using U2 = std::make_unsigned_t; bool accumulate = true; for (auto TC : Cases) { { // Test with two signed types @@ -101,15 +110,15 @@ assert(do_test(non_cce)); assert(do_test(non_cce)); - static_assert(do_test< int8_t>(), ""); - static_assert(do_test(), ""); - static_assert(do_test(), ""); - static_assert(do_test(), ""); + static_assert(do_test(), ""); + static_assert(do_test(), ""); + static_assert(do_test(), ""); + static_assert(do_test(), ""); - assert(do_test< int8_t>(non_cce)); - assert(do_test(non_cce)); - assert(do_test(non_cce)); - assert(do_test(non_cce)); + assert(do_test(non_cce)); + assert(do_test(non_cce)); + assert(do_test(non_cce)); + assert(do_test(non_cce)); static_assert(do_test(), ""); static_assert(do_test(), ""); @@ -131,9 +140,9 @@ // LWG#2837 { - auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648); - (void) std::lcm(INT_MIN, 2); // this used to trigger UBSAN - static_assert( std::is_same::type>::value, ""); + auto res1 = std::lcm(static_cast(1234), INT32_MIN); + (void)std::lcm(INT_MIN, 2UL); // this used to trigger UBSAN + static_assert(std::is_same::value, ""); assert(res1 == 1324997410816LL); } }