@@ -776,7 +776,8 @@ cgConst c@(TT.Str s) = do
776 str <- addGlobal' (ArrayType (1 + fromIntegral (length s)) (IntegerType 8)) (cgConst' c)
776 str <- addGlobal' (ArrayType (1 + fromIntegral (length s)) (IntegerType 8)) (cgConst' c)
777 box FString (ConstantOperand $ C.GetElementPtr True str [C.Int 32 0, C.Int 32 0])
777 box FString (ConstantOperand $ C.GetElementPtr True str [C.Int 32 0, C.Int 32 0])
778cgConst c@(TT.BI i) = do
778cgConst c@(TT.BI i) = do
779− str <- addGlobal' (ArrayType (1 + fromInteger (numDigits 10 i)) (IntegerType 8)) (cgConst' c)
779+ let stringRepLen = (if i < 0 then 2 else 1) + fromInteger (numDigits 10 i)
780+ str <- addGlobal' (ArrayType stringRepLen (IntegerType 8)) (cgConst' c)
780 mpz <- alloc mpzTy
781 mpz <- alloc mpzTy
781 inst $ simpleCall "__gmpz_init_set_str" [mpz
782 inst $ simpleCall "__gmpz_init_set_str" [mpz
782 , ConstantOperand $ C.GetElementPtr True str [ C.Int 32 0, C.Int 32 0]
783 , ConstantOperand $ C.GetElementPtr True str [ C.Int 32 0, C.Int 32 0]