GHC appears to loop

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sun Feb 4 09:12:23 EST 2007


Would you say this the same as the one described in the user guide?

http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs.html#bugs-ghc

        GHC's inliner can be persuaded into non-termination using the
        standard way to encode recursion via a data type:
        
          data U = MkU (U -> Bool)
               
          russel :: U -> Bool
          russel u@(MkU p) = not $ p u
          
          x :: Bool
          x = russel (MkU russel)
        
        We have never found another class of programs, other than this
        contrived one, that makes GHC diverge, and fixing the problem
        would impose an extra overhead on every compilation. So the bug
        remains un-fixed. There is more background in Secrets of the GHC
        inliner.
        

Duncan


On Sun, 2007-02-04 at 13:49 +0000, Wouter Swierstra wrote:
> When I try to compile to the following program, GHC seems to loop:
> 
> data Evil = Evil (Evil -> Evil)
> 
> instance Show Evil where
>    show _ = "t"
> 
> apply :: Evil -> Evil -> Evil
> apply (Evil f) x = f x
> 
> delta :: Evil
> delta = Evil (\x -> x `apply` x)
> 
> omega :: Evil
> omega = delta `apply` delta
> 
> main = print omega
> 
> The program codes up a non-terminating term omega - very similar to  
> (\x -> x x) (\x -> x x) - without using recursion. The trick is to  
> define an Evil data type which has a negative occurrence of Evil.
> 
> I realize it's a contrived example, but I wasn't sure if it's a known  
> issue. In case it matters, I'm using GHC 6.6 on a PowerPC Mac.
> 
> All the best,
> 
>    Wouter




More information about the Glasgow-haskell-users mailing list