Skip to content

heap overflow with Bits.shift and Integer

The following few lines produce a GHC panic:

module Main where

import Data.Bits (shift)

badOne :: [Int] -> Integer     -- replace Integer by Int and all is good!
badOne is = sum $ zipWith (\n _->shift 1 n) [0..] is

main = return () :: IO ()

The function is stripped down as much as possible, it doesn't perform anything all to meaningful anymore.

The error message is:

ghc: panic! (the 'impossible' happened)
  (GHC version 8.4.3 for x86_64-apple-darwin):
	heap overflow

All else is off-the-shelf stack lts-12.10 via

stack new bad-one simple

Tested on Mac OS X and Debian.

This has some resemblance with #14959, which was fixed in 8.4.2.

Edited by mcmayer
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information