Change std::ceil2 to be undefined if the result can't be represented
authorJonathan Wakely <jwakely@redhat.com>
Mon, 22 Jul 2019 16:53:27 +0000 (17:53 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 22 Jul 2019 16:53:27 +0000 (17:53 +0100)
commit281ab2fbff7398643352e86fcddc83098efd6310
tree5e500b94f761c64dfe86debc7cf2745280099424
parent462e6f9a932a44ca73715dc5c2960e5b332f63f7
Change std::ceil2 to be undefined if the result can't be represented

* include/std/bit (__ceil2): Make unrepresentable results undefined,
as per P1355R2. Add debug assertion. Perform one left shift, not two,
so that out of range values cause undefined behaviour. Ensure that
shift will still be undefined if left operand is promoted.
* testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Replace checks for
unrepresentable values with checks that they are not core constant
expressions.
* testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc: New test.

From-SVN: r273705
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/bit
libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc
libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc [new file with mode: 0644]