Skip to content

ByteArray# return value can lead to trouble

GHC in some circumstances has problems with functions 
returning values of type `ByteArray#'.  The following is
bogus code, but it shouldn't result in a panic:

module Test
where
import PrelGHC
import PrelBase
import PrelST

die :: Int -> ByteArray#
{-# NOINLINE die #-}
die _ = undefined

foo = I# (indexIntArray# (die 0) 0#)

With GHC 4.11 (couple of weeks old), I get

  ghc: panic! (the `impossible' happened):
  	  mkPrimReturnCode: Upd c_sPk

when compiling with

  ghc -c -O -fglasgow-exts test.hs

For the problem to occur, both -O and the NOINLINE pragma are 
required.
Trac metadata
Trac field Value
Version None
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedFixed
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