[commit: ghc] wip/T10137: Fix two off-by-one errors (21d975a)

git at git.haskell.org git at git.haskell.org
Sun Mar 8 19:30:29 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T10137
Link       : http://ghc.haskell.org/trac/ghc/changeset/21d975a7d095b1a0c074396055ce9d23afd458bf/ghc

>---------------------------------------------------------------

commit 21d975a7d095b1a0c074396055ce9d23afd458bf
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Sun Mar 8 20:00:55 2015 +0100

    Fix two off-by-one errors


>---------------------------------------------------------------

21d975a7d095b1a0c074396055ce9d23afd458bf
 compiler/cmm/CmmSwitch.hs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/compiler/cmm/CmmSwitch.hs b/compiler/cmm/CmmSwitch.hs
index 4bd905e..bbc1199 100644
--- a/compiler/cmm/CmmSwitch.hs
+++ b/compiler/cmm/CmmSwitch.hs
@@ -167,7 +167,7 @@ mkFlatSwitchPlan Nothing _ (m:ms)
 mkFlatSwitchPlan (Just l) r ms = let ((_,p1):ps) = go r ms in (p1, ps)
   where
     go (lo,hi) []
-        | lo >= hi = []
+        | lo > hi = []
         | otherwise = [(lo, Unconditionally l)]
     go (lo,hi) (m:ms)
         | lo < min
@@ -223,12 +223,11 @@ addRange (SwitchTargets Nothing Nothing m) = ((lo,hi), m, id)
   where (lo,_) = M.findMin m
         (hi,_) = M.findMax m
 
--- No range, but a default. Make set the range, but also return the necessary
--- branching
+-- No range, but a default. Create a range, but also emit SwitchPlans for outside the range
 addRange (SwitchTargets Nothing (Just l) m)
     = ( (lo,hi)
       , m
-      , \plan -> (Unconditionally l, lo) `consSL` plan `snocSL` (hi, Unconditionally l)
+      , \plan -> (Unconditionally l, lo) `consSL` plan `snocSL` (hi+1, Unconditionally l)
       )
   where (lo,_) = M.findMin m
         (hi,_) = M.findMax m



More information about the ghc-commits mailing list