diff options
Diffstat (limited to 'libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc')
-rw-r--r-- | libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc index 65e1569..e41f82c 100644 --- a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc +++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc @@ -55,6 +55,14 @@ test(UInt x) static_assert( std::ceil2(UInt(3) << 64) == (UInt(4) << 64) ); } + constexpr UInt msb = UInt(1) << (std::numeric_limits<UInt>::digits - 1); + static_assert( std::ceil2( msb ) == msb ); + // Larger values cannot be represented so the return value is unspecified, + // but must still be valid in constant expressions, i.e. not undefined. + static_assert( std::ceil2( UInt(msb + 1) ) != 77 ); + static_assert( std::ceil2( UInt(msb + 2) ) != 77 ); + static_assert( std::ceil2( UInt(msb + 77) ) != 77 ); + return true; } |