[libcxx-commits] [libcxx] Fix one case in saturate_cast.pass.cpp for 64-bit on z/OS (PR #86724)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 26 12:56:33 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: None (zibi2)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/86724.diff
1 Files Affected:
- (modified) libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp (+1-1)
``````````diff
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..59f397d5c0ee76 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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/86724
More information about the libcxx-commits
mailing list