#5569: Ineffective seq/BangPatterns
----------------------------------+-----------------------------------------
Reporter: daniel.is.fischer | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.2.1 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
----------------------------------+-----------------------------------------
This could be related to #5557, but it might be something else.
7.2.1 was very picky about where you placed your bangs/seqs, for example
{{{
{-# LANGUAGE BangPatterns #-}
module Main (main) where
main :: IO ()
main = print (f 1000000)
f :: Integer -> Integer
f n = go n 0
where
go 0 !sm = sm
go k acc = go (k-1) (acc+k)
OR
module Main (main) where
main :: IO ()
main = print (f 1000000)
f :: Integer -> Integer
f n = go n 0
where
go a b | a `seq` b `seq` False = undefined
go k acc
| k == 0 = acc
| otherwise = go (k-1) (acc+k)
}}}
gave a stack overflow when compiled with ghc -O2. You have to place the
bang/seq on the second equation for it to work. Older ghc versions treated
it well, as does HEAD, so it seems fixed, but perhaps a regression test is
in order?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5569>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs