Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fix cast in C_random_fixnum so it doesn't cause overflow and truncati…

…on on amd64 for large arguments like most-positive-fixnum (as used in hash-tables)

Signed-off-by: felix <>
(cherry picked from commit 140d713)
  • Loading branch information...
commit ab8b1a3cc615d3bfeba71e39c5fbd0faa519714a 1 parent 2a7de60
Peter Bex authored committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  chicken.h
2  chicken.h
@@ -1122,7 +1122,7 @@ extern double trunc(double);
C_unfix(end1) - C_unfix(start1) ), C_SCHEME_UNDEFINED)
#define C_words(n) C_fix(C_bytestowords(C_unfix(n)))
#define C_bytes(n) C_fix(C_wordstobytes(C_unfix(n)))
-#define C_random_fixnum(n) C_fix((int)(((double)rand())/(RAND_MAX + 1.0) * C_unfix(n)))
+#define C_random_fixnum(n) C_fix((C_word)(((double)rand())/(RAND_MAX + 1.0) * C_unfix(n)))
#define C_randomize(n) (srand(C_unfix(n)), C_SCHEME_UNDEFINED)
#define C_block_size(x) C_fix(C_header_size(x))
#define C_pointer_address(x) ((C_byte *)C_block_item((x), 0))

0 comments on commit ab8b1a3

Please sign in to comment.
Something went wrong with that request. Please try again.