Large constants in *.cmm files

Sven Panne Sven.Panne at aedion.de
Sun Sep 12 10:40:51 EDT 2004


Although I'm not a C-- expert, the following part of the RTS compilation looks
wrong:

    [...]
    ../../ghc/compiler/ghc-inplace -H16m -O -O2 -static -#include Prelude.h -#include Rts.h -#include RtsFlags.h -#include RtsUtils.h -#include StgRun.h -#include Schedule.h -#include Printer.h -#include Sanity.h -#include Storage.h -#include SchedAPI.h -#include Timer.h -#include Itimer.h -#include ProfHeap.h -#include LdvProfile.h -#include Profiling.h -#include Apply.h -fvia-C -dcmm-lint     -c PrimOps.cmm -o PrimOps.o
    /tmp/ghc2101.hc: In function `int64ToIntegerzh_fast':
    /tmp/ghc2101.hc:387: warning: integer constant is too large for "long" type
    /tmp/ghc2101.hc:388: warning: integer constant is too large for "long" type
    /tmp/ghc2101.hc: In function `word64ToIntegerzh_fast':
    /tmp/ghc2101.hc:451: warning: integer constant is too large for "long" type
    /tmp/ghc2101.hc:464: warning: integer constant is too large for "long" type
    [...]

One of the relevant parts of PrimOps.cmm is:

    [...]
    if ( %ge(val,0x100000000::L_) || %le(val,-0x100000000::L_) )  {
    [...]

And the *.hc generated for this:

    [...]

	if ((StgInt64)_c1M >= (StgInt64)0x100000000) goto _c8w;
	if ((StgInt64)_c1M <= (StgInt64)(-((StgInt64)0x100000000))) goto _c8w;
    [...]

Although C99 allows this (if I read the section "Integer constants" correctly),
it would probably be better to use an "LL" suffix for the constants in C.

Cheers,
    S.


More information about the Cvs-ghc mailing list