Skip to content

-O -g breaks string literals

With foo.hs:

main = print (4, "foo")

Compile it and run it like:

% ghc-stage2 -O -g foo.hs
% ./foo
(4,"\CANq@")

Note that the content of the string literal is broken, although the length is preserved.

With -dcore-lint, the following error is produced:

*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
    [RHS of ww2_s3hG :: Addr#]
    Recursive or top-level binder has strict demand info: ww2_s3hG
    Binder's demand info: <L,U>

The offending binding is:

ww2_s3hG :: Addr#
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
ww2_s3hG = src<foo.hs:1:18-22> "foo"#

Happens with ghc 8.4.1-rc1 and with HEAD (df2c3b33).

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