
#8037: GHC panic when compiling unsafeCoerce ---------------------------+------------------------------------------------ Reporter: ghc@… | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.1 | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: ---------------------------+------------------------------------------------ The GHC compiler crashes on the following program. {{{ module Test where import Unsafe.Coerce import Graphics.Rendering.OpenGL (color, Color3, GLdouble) data D4 = D4 Double Double Double Double crash :: D4 -> IO () crash c = color (invalidCast c) invalidCast :: D4 -> Color3 GLdouble invalidCast = unsafeCoerce }}} With the following output: {{{ [1 of 1] Compiling Test ( Test.hs, Test.o ) ghc: panic! (the 'impossible' happened) (GHC version 7.6.1 for x86_64-apple-darwin): cgLookupPanic (probably invalid Core; try -dcore-lint) ww_s28U{v} [lid] static binds for: local binds for: }}} I've made several attempts to make the input program smaller, but all modifications will result in successful compilation. The cast is invalid but should produce an runtime error, not a compile time error. Changes I made that somehow prevent this bug from appearing: - Changing the `crash` functions into point free style `color . invalidCast`. - Decreasing the amount of doubles in the `D4` datatype. - Inlining the exact definitions from the OpenGL package. - Using the `print` function instead of the `color` function. (btw, I know I shouldn't use unsafeCoerce) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/8037 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler