[GHC] #5722: GHC inlines class method forever

GHC cvs-ghc at haskell.org
Sat Dec 24 03:46:39 CET 2011


#5722: GHC inlines class method forever
--------------------------------+-------------------------------------------
 Reporter:  benmachine          |          Owner:                  
     Type:  bug                 |         Status:  new             
 Priority:  normal              |      Component:  Compiler        
  Version:  7.2.1               |       Keywords:                  
       Os:  Unknown/Multiple    |   Architecture:  Unknown/Multiple
  Failure:  Compile-time crash  |       Testcase:                  
Blockedby:                      |       Blocking:                  
  Related:                      |  
--------------------------------+-------------------------------------------
 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5722>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list