store-merging: Apply --param=store-merging-max-size= in more spots [PR117439]
[official-gcc.git] / libstdc++-v3 / testsuite / 26_numerics / saturation / cast.cc
blob672e9c46be1c70159af52cebf3c304c4197ad6d0
1 // { dg-do compile { target c++26 } }
3 // C++26 Saturation arithmetic [numerics.sat]
5 #include <numeric>
6 #include <climits>
8 #if CHAR_BIT == 8
9 static_assert(std::saturate_cast<unsigned char>(999) == 255);
10 static_assert(std::saturate_cast<signed char>(999) == 127);
11 #endif
12 static_assert(std::saturate_cast<unsigned short>(999) == 999);
13 static_assert(std::saturate_cast<signed short>(999) == 999);
14 static_assert(std::saturate_cast<short>(INT_MAX) == SHRT_MAX);
15 static_assert(std::saturate_cast<short>(UINT_MAX) == SHRT_MAX);
16 static_assert(std::saturate_cast<short>(UINT_MAX) == SHRT_MAX);
17 static_assert(std::saturate_cast<unsigned short>(UINT_MAX) == USHRT_MAX);
18 static_assert(std::saturate_cast<int>(UINT_MAX) == INT_MAX);
19 static_assert(std::saturate_cast<int>(INT_MAX) == INT_MAX);
20 static_assert(std::saturate_cast<unsigned>(-1) == 0);
21 static_assert(std::saturate_cast<unsigned>(INT_MIN) == 0);
22 static_assert(std::saturate_cast<unsigned>(UINT_MAX) == UINT_MAX);
23 static_assert(std::saturate_cast<unsigned>(LLONG_MAX) == UINT_MAX);
24 static_assert(std::saturate_cast<unsigned>(ULLONG_MAX) == UINT_MAX);