#1752: space leak caused by $ vs. () with -O2
-----------------------+----------------------------------------------------
  Reporter:  guest     |          Owner:          
      Type:  bug       |         Status:  new     
  Priority:  normal    |      Milestone:          
 Component:  Compiler  |        Version:  6.6.1   
  Severity:  normal    |       Keywords:          
Difficulty:  Unknown   |             Os:  Windows 
  Testcase:            |   Architecture:  Multiple
-----------------------+----------------------------------------------------
 The following program exhibits a space leak on GHC6.6.1.  "noleak" doesn't
 exhibit the leak.  The only difference is choosing to use $ (leaky)
 instead of () (non-leaky).

 No leak happens if optimizations are off.

 Compiled with {{{c:\haskell> ghc -O2 --make fibsquares.hs}}}

 {{{
 module Main where

 fibs a b = a : fibs b (a+b)

 odds (x:xs) = evens xs
 evens (x:xs) = x : odds xs

 square x = x*x
 sumSucc xs = zipWith (+) xs (tail xs)

 main = spaceleak

 spaceleak =
     mapM_ print $ zip [0..] $ takeWhile id $
     zipWith (==) (odds $ fibs 0 1) $
     sumSucc $ map square $ fibs 0 1

 noleak =
     mapM_ print $ zip [0..] $ takeWhile id $
     zipWith (==) (odds $ fibs 0 1)
     (sumSucc $ map square $ fibs 0 1)
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1752>
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

Reply via email to