Skip to content

Commit 6e6d266

Browse files
zibi2perry-ca
andauthored
[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 <[email protected]>
1 parent 2fa46ca commit 6e6d266

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ constexpr bool test() {
329329
{ [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(sBigMax); }
330330
assert(std::saturate_cast<unsigned long int>( sBigMin) == 0UL); // saturated
331331
assert(std::saturate_cast<unsigned long int>( sZero) == 0UL);
332-
assert(std::saturate_cast<unsigned long int>( sBigMax) == ULONG_MAX); // saturated
332+
assert(std::saturate_cast<unsigned long int>( sBigMax) == (sizeof(UIntT) > sizeof(unsigned long int) ? ULONG_MAX : LONG_MAX)); // saturated depending on underlying types
333333

334334
{ [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(uBigMax); }
335335
assert(std::saturate_cast<unsigned long int>( uZero) == 0UL);

0 commit comments

Comments
 (0)