[GHC] #14680: GHC 8.4.1-alpha panics when optimizing function using getTag and tagToEnum#

GHC ghc-devs at haskell.org
Wed Jan 17 17:28:27 UTC 2018


#14680: GHC 8.4.1-alpha panics when optimizing function using getTag and tagToEnum#
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  highest        |         Milestone:  8.4.1
          Component:  Compiler       |           Version:  8.4.1-alpha1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Compile-time
  Unknown/Multiple                   |  crash or panic
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I originally observed this panic in [https://travis-ci.org/haskell-compat
 /deriving-compat/jobs/329948624#L804 this Travis build]. The panic can be
 reduced to this file:

 {{{#!hs
 {-# LANGUAGE MagicHash #-}
 {-# LANGUAGE TypeFamilies #-}
 module Bug where

 import GHC.Base (getTag)
 import GHC.Exts (Int(..), tagToEnum#)

 data family TyFamilyEnum
 data instance TyFamilyEnum = TyFamilyEnum1 | TyFamilyEnum2 | TyFamilyEnum3

 suc :: TyFamilyEnum -> TyFamilyEnum
 suc a_aaf8
         = case getTag a_aaf8 of
              a_aaf9
                -> if 2 ==  I# a_aaf9
                   then error "succ{TyFamilyEnum}: tried to take `succ' of
 last tag in enumeration"
                   else case I# a_aaf9 + 1 of
                          I# i_aafa -> tagToEnum# i_aafa :: TyFamilyEnum
 }}}

 In GHC 8.2.2, compiling this with optimization works fine. But in GHC
 8.4.1-alpha, it panics:

 {{{
 $ /opt/ghc/8.4.1/bin/ghc -fforce-recomp -O1 Bug.hs
 [1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
 ghc: panic! (the 'impossible' happened)
   (GHC version 8.4.0.20171222 for x86_64-unknown-linux):
         Prelude.!!: index too large
 }}}

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


More information about the ghc-tickets mailing list