Skip to content

-ddump-cmm doesn't escape non-ascii/non-printable characters

For instance, the string literal "\102\232\13\0Hello, world!\n\178\14\89\179\1\176\4\205\128\49\192\195" came out of ghc --make -ddump-cmm hell.hs | less looking like:

    cUz_str:
        I8[] "fè^M<C0><80>Hello, world!
²^NY³^A°^DÍ<U+0080>1ÀÃ"

(with LANG=un_US.UTF-8 and a UTF-8 capable terminal; this value gets passed to unpackCStringUtf8#)

I also have to wonder what the point of using UTF-8 when the original string literal only contains characters in the range ['0'..'\255'] is...

The full program was:

`/x-haskell # LANGUAGE ForeignFunctionInterface # import Foreign.Ptr import Foreign.C.String

foreign import ccall "dynamic" mkFun :: FunPtr (IO ()) -> IO ()

code :: String code = "\102\232\13\0Hello, world!\n\178\14\89\179\1\176\4\205\128\49\192\195"

main :: IO () main = withCString code (mkFun . castPtrToFunPtr) `

Note: this doesn't seem to actually work :-(. Oh, right, I'm only setting the lowest 8 bits of each register. That explains that...

Trac metadata
Trac field Value
Version 6.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information