Skip to content

Wrong string generated via TH on big-endian architecture (T10620)

Summary

Running T10620 which is

{-# LANGUAGE MagicHash, TemplateHaskell #-}
module Main where

import Language.Haskell.TH

main :: IO ()
main = do
    putStrLn $([| 'a'#   |] >>= stringE . show)
    putStrLn $([| "abc"# |] >>= stringE . show)

on big-endian architecture S/390 results in a wrong string:

ghc T10620.hs -ddump-splices
[1 of 1] Compiling Main             ( T10620.hs, T10620.o, T10620.dyn_o )
T10620.hs:8:15-47: Splicing expression
    [| 'a'# |] >>= stringE . show ======> "LitE (CharPrimL 'a')"
T10620.hs:9:15-47: Splicing expression
    [| "abc"# |] >>= stringE . show
  ======>
    "LitE (StringPrimL [0,0,0])"
Linking T10620 ...

Any idea where I could start looking into?

Expected behavior

Instead of LitE (StringPrimL [0,0,0]) we expect LitE (StringPrimL [97,98,99]). Interestingly the character is generated just fine.

Environment

Optional:

  • Operating System: Fedora 33
  • System Architecture: S/390
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information