diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2017-02-10 20:49:08 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2017-02-10 20:49:08 +0000 |
| commit | 58fc1b50d8b0719460e1bf08734c0e7632fb03c4 (patch) | |
| tree | 9ac7cd4d201cdcd5222550d96aee2af453a1231c /libcxx/test/std/numerics | |
| parent | 278890f85bba9cf006944e67565dfdefece55d7c (diff) | |
| download | bcm5719-llvm-58fc1b50d8b0719460e1bf08734c0e7632fb03c4.tar.gz bcm5719-llvm-58fc1b50d8b0719460e1bf08734c0e7632fb03c4.zip | |
Make lcm/gcd work better in edge cases. Fixes a UBSAN failure.
llvm-svn: 294779
Diffstat (limited to 'libcxx/test/std/numerics')
| -rw-r--r-- | libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp | 1 | ||||
| -rw-r--r-- | libcxx/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp | 8 |
2 files changed, 4 insertions, 5 deletions
diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp index 0774bff40d1..961b515ef8d 100644 --- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 -// XFAIL: ubsan // <numeric> diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp index a74ac76a321..90d48398f54 100644 --- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 -// XFAIL: ubsan // <numeric> // template<class _M, class _N> @@ -132,8 +131,9 @@ int main() // LWG#2837 { - auto res = std::lcm((int64_t)1234, (int32_t)-2147483648); - static_assert( std::is_same<decltype(res), std::common_type<int64_t, int32_t>::type>::value, ""); - assert(res == -1324997410816LL); + 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); } } |

