Ticket #5722 (new bug)
GHC inlines class method forever
| Reported by: | benmachine | Owned by: | simonpj |
|---|---|---|---|
| Priority: | normal | Milestone: | _|_ |
| Component: | Compiler | Version: | 7.2.1 |
| Keywords: | Cc: | ireney.knapp@…, hvr@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Compile-time crash | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
irene-knapp showed me this over IRC, I refined the test case a bit:
{-# LANGUAGE FlexibleContexts, MultiParamTypeClasses #-}
module Bug () where
class C a b where
discord :: C a b => a b () -- Remove the constraint and it works
rhyme :: a b ()
instance C (,) b => C (,) [b] where
discord = discord
rhyme = discord
GHC 7.2.2 compiling this with -O loops forever. I've worked out:
- The C a b context in the class is completely superfluous but the bug isn't triggered without it.
- The pattern of recursion in the two method signatures is fragile: rhyme = rhyme doesn't trigger the bug, for example.
- Adding a NOINLINE discord stops the bug from triggering. Similarly, compiling without optimisations doesn't trigger the bug.
- While it's looping, GHC slowly but steadily chews through all of your memory.
Change History
Note: See
TracTickets for help on using
tickets.
