#5400: GHC loops on compiling with optimizations
-------------------------------+--------------------------------------------
    Reporter:  noschinl        |        Owner:                    
        Type:  bug             |       Status:  new               
    Priority:  normal          |    Milestone:  _|_               
   Component:  Compiler        |      Version:  7.0.4             
    Keywords:                  |     Testcase:                    
   Blockedby:                  |   Difficulty:                    
          Os:  Linux           |     Blocking:                    
Architecture:  x86_64 (amd64)  |      Failure:  Compile-time crash
-------------------------------+--------------------------------------------
Changes (by simonpj):

  * milestone:  => _|_


Comment:

 Interesting example!  This program should diverge, of course, but it
 should not do so at runtime.  Yet it turns out to be a disguised case of
 GHC's well-known compile-time divergence bug
 ([http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/bugs.html
 #bugs-ghc User manual 12.2.1, bullet 3]).

 Here is the desugaring of the program after dictionaries have become
 explicit:
 {{{
 data C a = MkC (C a -> Int)

 fH :: C Int -> Int
 fH x = case x of { MkC g -> g x }

 fCInt :: C Int   -- The instance decl for (C Int) gives this
 fCInt = MkC fH
 }}}
 Notice that
  * None of these definitions is recursive
  * But the data type `C a` has a `(C a)` on the left of an arrow.

 Now consider evaluating
 {{{
      fH fCInt

 --> (inline fH)
     case fCInt of MkC g -> g fCInt

 --> (inline fCInt and eliminate the case)
     fH fCInt

 and so on forever...
 }}}
 It's a classic example of the Russell-paradox loop.  The manual claims
 this "never happens in practice" and I guess this bug report is a counter-
 example!  However, it's not easy to fix this particular loop; and as you
 found, it's not a program you want to write anyway.

 See also #3872

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to