Skip to content

When using Word8# functions: Error: invalid instruction suffix for `lea'

Summary

Using some Word8# primitive functions results in invalid assembly. Possibly related to #18141 (closed) (which is already closed).

Steps to reproduce

{-# LANGUAGE MagicHash, UnboxedTuples #-}
{-# OPTIONS_GHC -O #-}

module Main where

import GHC.Exts

main = pure ()

test :: Word8# -> Word8#
test x = x `plusWord8#` narrowWord8# 1##

Result with GHC HEAD ( 8.11.0.20200824 )

[1 of 1] Compiling Main             ( UnboxedWord8.hs, UnboxedWord8.o )
/tmp/ghc3912_0/ghc_2.s: Assembler messages:

/tmp/ghc3912_0/ghc_2.s:52:0: error:
     Error: invalid instruction suffix for `lea'
   |
52 |         leab 1(%r14),%al
   | ^
`cc' failed in phase `Assembler'. (Exit code: 1)

Result with GHC 8.8.3

ghc: panic! (the 'impossible' happened)
  (GHC version 8.8.3 for x86_64-unknown-linux):
        Prelude.chr: bad argument: 808989236

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

Expected behavior

Program should compile and link without errors.

Environment

  • GHC version used: 8.8.3, 8.11.0.20200824

Linux, x86_64

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