~ chicken-core (chicken-5) 140d713a53416e487da0548129f7d6b8f7064097


commit 140d713a53416e487da0548129f7d6b8f7064097
Author:     Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Wed Feb 29 20:50:52 2012 +0100
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Sat Mar 3 14:10:50 2012 +0100

    Fix cast in C_random_fixnum so it doesn't cause overflow and truncation on amd64 for large arguments like most-positive-fixnum (as used in hash-tables)
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/chicken.h b/chicken.h
index b304d222..ffac46cd 100644
--- a/chicken.h
+++ b/chicken.h
@@ -1128,7 +1128,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))
Trap