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,6 +16,7 @@ #include #include +#include #include // for rand() #include @@ -36,11 +37,19 @@ 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; } @@ -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 @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -34,11 +35,19 @@ }; 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; } @@ -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, 2); // this used to trigger UBSAN + static_assert(std::is_same>::value, ""); assert(res1 == 1324997410816LL); } }