diff options
Diffstat (limited to 'test/std/numerics/numeric.ops')
4 files changed, 22 insertions, 4 deletions
diff --git a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp index 46741e1e41b7b..f999c5045a5c1 100644 --- a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp +++ b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp @@ -22,6 +22,7 @@ #include <numeric> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class InIter, class OutIter> @@ -38,7 +39,7 @@ test() assert(ib[i] == ir[i]); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 class Y; @@ -107,7 +108,7 @@ int main() test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 X x[3] = {X(1), X(2), X(3)}; Y y[3] = {Y(1), Y(2), Y(3)}; std::adjacent_difference(x, x+3, y); diff --git a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp index fb0bbdc2836da..8a30a82212de1 100644 --- a/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp +++ b/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp @@ -23,6 +23,7 @@ #include <functional> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" template <class InIter, class OutIter> @@ -40,7 +41,7 @@ test() assert(ib[i] == ir[i]); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 class Y; @@ -110,7 +111,7 @@ int main() test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 X x[3] = {X(1), X(2), X(3)}; Y y[3] = {Y(1), Y(2), Y(3)}; std::adjacent_difference(x, x+3, y, std::minus<X>()); diff --git a/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp index af065b84d1bb1..961b515ef8d88 100644 --- a/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp +++ b/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 + // <numeric> // template<class _M, class _N> @@ -129,4 +130,11 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2837 + { + auto res = std::gcd((int64_t)1234, (int32_t)-2147483648); + static_assert( std::is_same<decltype(res), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res == 2); + } } diff --git a/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp b/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp index cd03d99ebf131..90d48398f54a7 100644 --- a/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp +++ b/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp @@ -128,4 +128,12 @@ int main() assert((do_test<long, int>(non_cce))); assert((do_test<int, long long>(non_cce))); assert((do_test<long long, int>(non_cce))); + +// LWG#2837 + { + auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648); + (void) std::lcm<int, unsigned long>(INT_MIN, 2); // this used to trigger UBSAN + static_assert( std::is_same<decltype(res1), std::common_type<int64_t, int32_t>::type>::value, ""); + assert(res1 == 1324997410816LL); + } } |