Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/291da8a0624d3844d30931d0e89f51e3daf03a61 >--------------------------------------------------------------- commit 291da8a0624d3844d30931d0e89f51e3daf03a61 Author: Ian Lynagh <[email protected]> Date: Fri Sep 14 12:53:13 2012 +0100 Check for Int constants that are too large in mkDerivedConstants >--------------------------------------------------------------- includes/mkDerivedConstants.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c index 92024d3..28377ef 100644 --- a/includes/mkDerivedConstants.c +++ b/includes/mkDerivedConstants.c @@ -294,6 +294,20 @@ enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haske #define FUN_OFFSET(sym) (OFFSET(Capability,f.sym) - OFFSET(Capability,r)) void constantInt(char *name, intptr_t val) { + /* If the value is larger than 2^28 or smaller than -2^28, then fail. + This test is a bit conservative, but if any constants are roughly + maxBoun or minBound then we probably need them to be Integer + rather than Int so that cross-compiling between 32bit and 64bit + platforms works. */ + if (val > 268435456) { + printf("Value too large for constantInt: %" PRIdPTR "\n", val); + exit(1); + } + if (val < -268435456) { + printf("Value too small for constantInt: %" PRIdPTR "\n", val); + exit(1); + } + switch (mode) { case Gen_Haskell_Type: printf(" , pc_%s :: Int\n", name); _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
