Opened 4 years ago

Closed 4 years ago

#10518 closed bug (fixed)

unregisterised GHC generates incorrect 0xUL literals for certain onstants

Reported by: slyfox Owned by: slyfox
Priority: normal Milestone: 7.10.2
Component: Compiler Version: 7.10.1
Keywords: Cc: jakzale
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: codeGen/should_compile/T10518
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D987
Wiki Page:

Description (last modified by int-e)

jakzale reports: 21:47:27 < int-e> Oh, nice. Yes, indeed pprHexVal (232) W32 (function from cmm/PprC.hs) would result in 0xU. 21:50:29 < jakzale> int-e: yes, truncInt takes module 232, then go returns empty string (I guess)

Here comes the test:

$ cat a.cmm

foo() {
    bits64 a;
    a = 0x10000000000000000; // overflows 64 bits
    return (a);

$ inplace/bin/ghc-stage2 -c a.cmm
/tmp/ghc8580_0/ghc_2.hc: In function 'foo':

/tmp/ghc8580_0/ghc_2.hc:8:7: error:
     error: invalid suffix "xUL" on integer constant
     _c0 = 0xUL;

I've broke it with commit:43f1b2ecd1960fa7377cf55a2b97c66059a701ef when introduced truncation that can generate more zeroes.

Change History (7)

comment:1 Changed 4 years ago by jakzale

Cc: jakzale added

comment:2 Changed 4 years ago by int-e

Description: modified (diff)

comment:3 Changed 4 years ago by slyfox

Differential Rev(s): Phab:D987

comment:4 Changed 4 years ago by Sergei Trofimovich <siarheit@…>

In a5084557b0b30faf3f89386ee6ee5a308dae51b1/ghc:

UNREG: fix pprHexVal to emit zeros (#10518)

jakzale on #ghc reported a build failure
when ported GHC on a new target.

The code 'pprHexVal (2^32) W32' emits '0xU'
which is invalid C.

I've introduced bug in
when added literal truncation. That truncation
is a new source of zeros.

Signed-off-by: Sergei Trofimovich <>

Test Plan: added test and tested on UNREG ghc

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10518

comment:5 Changed 4 years ago by slyfox

Milestone: 7.10.2
Test Case: codeGen/should_compile/T10518
Type of failure: None/UnknownCompile-time crash

comment:6 Changed 4 years ago by slyfox

Status: newmerge

comment:7 Changed 4 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed

Merged to ghc-7.10.

Note: See TracTickets for help on using tickets.