Avoid undefined shifts in ceil2 operations
authorJonathan Wakely <jwakely@redhat.com>
Thu, 30 Aug 2018 15:07:35 +0000 (16:07 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 30 Aug 2018 15:07:35 +0000 (16:07 +0100)
commit2fb17d2d901d904479fa22dd01b887ff5bc48248
tree111035d748bf025dcc5d4a417edde0802112332d
parent2ebbdb6ca3f69cdac97aeba48a7f00ea40337cd5
Avoid undefined shifts in ceil2 operations

For values where the result cannot be represented the shift width would
be equal to the width of the type, which is undefined. Perform two
well-defined shifts instead of one possible undefined shift.

* include/bits/hashtable_policy.h (__clp2): Fix calculation for LLP64
targets where sizeof(size_t) > sizeof(long). Avoid undefined shifts
of the number of bits in the type.
* include/std/bit (__ceil2): Avoid undefined shifts.
* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Test values with
the most signifiant bit set.

From-SVN: r263986
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/hashtable_policy.h
libstdc++-v3/include/std/bit
libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc