[commit: ghc] ghc-7.10: Ensure shiftL/shiftR arguments aren't negative (2e87fd1)
git at git.haskell.org
git at git.haskell.org
Wed Oct 7 06:51:38 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.10
Link : http://ghc.haskell.org/trac/ghc/changeset/2e87fd1b453360ada9ca5bfc267c0a904ab1241d/ghc
>---------------------------------------------------------------
commit 2e87fd1b453360ada9ca5bfc267c0a904ab1241d
Author: Ben Gamari <ben at smart-cactus.org>
Date: Tue Oct 6 19:30:50 2015 +0200
Ensure shiftL/shiftR arguments aren't negative
Fixes #10571.
>---------------------------------------------------------------
2e87fd1b453360ada9ca5bfc267c0a904ab1241d
libraries/base/Data/Bits.hs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs
index 84b1c03..38025f8 100644
--- a/libraries/base/Data/Bits.hs
+++ b/libraries/base/Data/Bits.hs
@@ -515,8 +515,12 @@ instance Bits Integer where
complement = complementInteger
shift x i@(I# i#) | i >= 0 = shiftLInteger x i#
| otherwise = shiftRInteger x (negateInt# i#)
- shiftL x (I# i#) = shiftLInteger x i#
- shiftR x (I# i#) = shiftRInteger x i#
+ shiftL x i@(I# i#)
+ | i < 0 = error "Bits.shiftL(Integer): negative shift"
+ | otherwise = shiftLInteger x i#
+ shiftR x i@(I# i#)
+ | i < 0 = error "Bits.shiftR(Integer): negative shift"
+ | otherwise = shiftRInteger x i#
testBit x (I# i) = testBitInteger x i
More information about the ghc-commits
mailing list