[GHC] #13458: Panic with unsafeCoerce and -dcore-lint
GHC
ghc-devs at haskell.org
Mon Mar 20 06:45:06 UTC 2017
#13458: Panic with unsafeCoerce and -dcore-lint
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler (Type | Version: 8.1
checker) |
Resolution: | 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: |
-------------------------------------+-------------------------------------
Description changed by dfeuer:
Old description:
> {{{#!hs
> {-# LANGUAGE MagicHash, TypeInType, ScopedTypeVariables #-}
> module UIOST where
> import GHC.Exts
> import Data.Kind
> import Unsafe.Coerce
>
> unsafeCoerce' :: forall (r :: RuntimeRep)
> (a :: TYPE r) (b :: TYPE r).
> a -> b
> unsafeCoerce' = unsafeCoerce unsafeCoerce
> }}}
>
> Compiling this with optimization and `-dcore-lint` produces a panic:
>
> {{{
> ghc-stage2: panic! (the 'impossible' happened)
> (GHC version 8.1.20170308 for x86_64-unknown-linux):
> runtimeRepPrimRep
> typePrimRep (a_aW7 :: TYPE r_aW6)
> r_aW6
> Call stack:
> CallStack (from HasCallStack):
> prettyCurrentCallStack, called at
> compiler/utils/Outputable.hs:1191:58 in ghc:Outputable
> callStackDoc, called at compiler/utils/Outputable.hs:1195:37 in
> ghc:Outputable
> pprPanic, called at compiler/simplStg/RepType.hs:360:5 in
> ghc:RepType
> }}}
>
> Using `unsafeCoerce# unsafeCoerce` produces the panic without
> optimization. I have not been able to reproduce the problem without
> `-dcore-lint`.
New description:
{{{#!hs
{-# LANGUAGE MagicHash, TypeInType, ScopedTypeVariables #-}
module UIOST where
import GHC.Exts
import Data.Kind
import Unsafe.Coerce
unsafeCoerce' :: forall (r :: RuntimeRep)
(a :: TYPE r) (b :: TYPE r).
a -> b
unsafeCoerce' = unsafeCoerce id
}}}
Compiling this with optimization and `-dcore-lint` produces a panic:
{{{
ghc-stage2: panic! (the 'impossible' happened)
(GHC version 8.1.20170308 for x86_64-unknown-linux):
runtimeRepPrimRep
typePrimRep (a_aW7 :: TYPE r_aW6)
r_aW6
Call stack:
CallStack (from HasCallStack):
prettyCurrentCallStack, called at
compiler/utils/Outputable.hs:1191:58 in ghc:Outputable
callStackDoc, called at compiler/utils/Outputable.hs:1195:37 in
ghc:Outputable
pprPanic, called at compiler/simplStg/RepType.hs:360:5 in
ghc:RepType
}}}
Using `unsafeCoerce# id` produces the panic without optimization. I have
not been able to reproduce the problem without `-dcore-lint`.
--
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13458#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list