Crash compiling HPC with certain unsafe code
Summary
When compiling certain code that uses both unsafeCoerce
and reallyUnsafePtrEquality#
, the compiler crashes with an incomplete pattern match.
Steps to reproduce
Compile the following module with ghc -fhpc
:
{-# LANGUAGE MagicHash #-}
module HPsea where
import GHC.Exts
import Unsafe.Coerce
hetPtrEq :: a -> b -> Bool
hetPtrEq x y = isTrue# (unsafeCoerce (reallyUnsafePtrEquality# :: x -> x -> Int#) x y)
This crashes:
[1 of 1] Compiling HPsea ( HPsea.hs, HPsea.o ) [Source file changed]
<no location info>: error:
compiler/GHC/StgToCmm/Prim.hs:(340,32)-(341,74): Non-exhaustive patterns in lambda
I have not, thus far, been able to reproduce the problem without unsafeCoerce
or without reallyUnsafePtrEquality#
, but I admit I haven't tried terribly hard.
Expected behavior
I expect the code to compile successfully, and definitely not to crash the compiler.
Environment
- GHC version used: 9.8.2
Optional:
- Operating System:
- System Architecture: