#5920: stack overflow in strict function depending on return type
---------------------------------+------------------------------------------
    Reporter:  ben0x539          |       Owner:                  
        Type:  bug               |      Status:  new             
    Priority:  normal            |   Milestone:  7.6.1           
   Component:  Compiler          |     Version:  7.4.1           
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  Runtime crash   
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by pcapriotti):

  * difficulty:  => Unknown
  * milestone:  => 7.6.1


Comment:

 Thanks for the report.

 This doesn't seem to be related to strictness, but rather the
 boxing/unboxing of the `Int` result, which makes the function non-tail
 recursive. Probably the same issue as #4301.

 Here's the generated Core for the `goInt` function:

 {{{

 Rec {
 Main.$wgoInt [Occ=LoopBreaker]
   :: GHC.Integer.Type.Integer
      -> GHC.Integer.Type.Integer -> GHC.Prim.Int#
 [GblId, Arity=2, Str=DmdType SS]
 Main.$wgoInt =
   \ (w_s1Jb :: GHC.Integer.Type.Integer)
     (w1_s1Jc :: GHC.Integer.Type.Integer) ->
     let {
       $wfail_s1Ji :: GHC.Types.Int
       [LclId, Str=DmdType]
       $wfail_s1Ji =
         case GHC.Integer.Type.eqInteger w1_s1Jc lvl1_r1JJ of _ {
           GHC.Types.False ->
             case Main.$wgoInt
                    w_s1Jb (GHC.Integer.Type.plusInteger w1_s1Jc
 Main.main3)
             of ww_s1Jf { __DEFAULT ->
             GHC.Types.I# ww_s1Jf
             };
           GHC.Types.True ->
             case Main.$wgoInt
                    (GHC.Integer.Type.plusInteger w_s1Jb Main.main3)
 Main.main3
             of ww_s1Jf { __DEFAULT ->
             GHC.Types.I# ww_s1Jf
             }
         } } in
     case GHC.Integer.Type.eqInteger w_s1Jb lvl_r1JI of _ {
       GHC.Types.False ->
         case $wfail_s1Ji of _ { GHC.Types.I# ww1_s1Jf -> ww1_s1Jf };
       GHC.Types.True ->
         case GHC.Integer.Type.eqInteger w1_s1Jc lvl1_r1JJ of _ {
           GHC.Types.False ->
             case $wfail_s1Ji of _ { GHC.Types.I# ww1_s1Jf -> ww1_s1Jf };
           GHC.Types.True -> 0
         }
     }
 end Rec }
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5920#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