[libcxx-commits] [libcxx] 6e6d266 - [libc++] Fix one case in saturate_cast.pass.cpp for 64-bit on z/OS (#86724)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 27 06:50:30 PDT 2024
Author: zibi2
Date: 2024-03-27T09:50:25-04:00
New Revision: 6e6d266fb8cc1398e7d5a220a9332d88ce074464
URL: https://github.com/llvm/llvm-project/commit/6e6d266fb8cc1398e7d5a220a9332d88ce074464
DIFF: https://github.com/llvm/llvm-project/commit/6e6d266fb8cc1398e7d5a220a9332d88ce074464.diff
LOG: [libc++] Fix one case in saturate_cast.pass.cpp for 64-bit on z/OS (#86724)
On z/OS int128 is disabled causing one of the cases in
`saturate_cast.pass.cpp` to fail. The failure is only in 64-bit mode.
In this case `the std::numeric_limits<long long int>::max()` is within
`std::numeric_limits<unsigned long int>::min()`
and `std::numeric_limits<unsigned long int>::max()` therefore,
saturate_cast<unsigned long int>( sBigMax) == LONG_MAX and not ULONG_MAX
as original test.
In 32-bit, `saturate_cast<unsigned long int>( sBigMax) == ULONG_MAX`
like on other platforms where int128 is enabled.
This PR is required to pass this test case on z/OS and possibly on other
platforms where int128 is not supported/enabled.
---------
Co-authored-by: Sean Perry <perry at ca.ibm.com>
Added:
Modified:
libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp
index c06a9ed2d5cb42..cbca37e3a66139 100644
--- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp
@@ -329,7 +329,7 @@ constexpr bool test() {
{ [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(sBigMax); }
assert(std::saturate_cast<unsigned long int>( sBigMin) == 0UL); // saturated
assert(std::saturate_cast<unsigned long int>( sZero) == 0UL);
- assert(std::saturate_cast<unsigned long int>( sBigMax) == ULONG_MAX); // saturated
+ assert(std::saturate_cast<unsigned long int>( sBigMax) == (sizeof(UIntT) > sizeof(unsigned long int) ? ULONG_MAX : LONG_MAX)); // saturated depending on underlying types
{ [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(uBigMax); }
assert(std::saturate_cast<unsigned long int>( uZero) == 0UL);
More information about the libcxx-commits
mailing list