Ticket #3437 (closed bug: fixed)
Optimizer creates space leak on simple code
Description
The following code should run in constant space:
{-# LANGUAGE BangPatterns #-}
go (x:xs) !n !k = go xs 0 (n+k+1)
main = print (go (repeat 'x') 0 0 :: Int)
However, when compiled with -O2, it rapidly eats up the heap. If n and k are forced to be Int rather than Integer, the problem disappears.
Core for the above with -O2 is here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8268
The original code from which this was taken is here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8266
Change History
Note: See
TracTickets for help on using
tickets.
