[commit: base] ghc-7.4: Fix bug in popCountDefault. Fixes #5872 (61ace69)
Paolo Capriotti
p.capriotti at gmail.com
Tue Mar 6 18:54:10 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : ghc-7.4
http://hackage.haskell.org/trac/ghc/changeset/61ace69581034fc33bb3b628d6a3b947bb262dec
>---------------------------------------------------------------
commit 61ace69581034fc33bb3b628d6a3b947bb262dec
Author: Johan Tibell <johan.tibell at gmail.com>
Date: Tue Feb 14 09:38:19 2012 -0800
Fix bug in popCountDefault. Fixes #5872
Also add an INLINABLE pragma so that the function can be specialized at
the call site.
Merged from commit f4cc96cd1a9d78ee250c8f26797e0b72a8008a1c
>---------------------------------------------------------------
Data/Bits.hs | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Data/Bits.hs b/Data/Bits.hs
index c81c96f..6639698 100644
--- a/Data/Bits.hs
+++ b/Data/Bits.hs
@@ -238,7 +238,8 @@ class (Eq a, Num a) => Bits a where
popCount = go 0
where
go !c 0 = c
- go c w = go (c+1) (w .&. w - 1) -- clear the least significant bit set
+ go c w = go (c+1) (w .&. (w - 1)) -- clear the least significant bit set
+ {-# INLINABLE popCountDefault #-}
{- This implementation is intentionally naive. Instances are
expected to override it with something optimized for their
size. -}
More information about the Cvs-libraries
mailing list