Ticket #876 (closed bug: fixed)
Length is not a good consumer
| Reported by: | ariep@… | Owned by: | |
|---|---|---|---|
| Priority: | lowest | Milestone: | 7.6.2 |
| Component: | libraries/base | Version: | 6.5 |
| Keywords: | length | Cc: | rich.neswold@…, george.colpitts@… |
| Operating System: | Linux | Architecture: | Unknown/Multiple |
| Type of failure: | Runtime performance bug | Difficulty: | Unknown |
| Test Case: | perf/should_run/T876 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
The program
module Main where main = print $ length . filter odd $ [0 .. 999999999]
, compiled with ghc-6.5.20060508 or later with optimisation turned on (-O), overflows the stack when run. It seems that the generated code is not tail-recursive. 6.4.2 and 6.5 snapshots up to 20060507 do not have this problem.
This may be a silly example, but the same thing happens if you replace 'odd' with some more interesting predicate, and let the length of the input list be chosen by the user.
Change History
Note: See
TracTickets for help on using
tickets.
