Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,862
    • Issues 4,862
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8037
Closed
Open
Created Jul 04, 2013 by ghc@orangesquash.org.uk@trac-ghc

GHC panic when compiling unsafeCoerce

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)

Trac metadata
Trac field Value
Version 7.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking