Opened 2 hours ago
#1867 new defect
Cannot display literal values over 2^30 but within fixnum 64-bit range when declaring fixnum-arithmetic
| Reported by: | leo-ard | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | someday |
| Component: | unknown | Version: | 5.4.0 |
| Keywords: | Cc: | ||
| Estimated difficulty: |
Description
Hi!
I encountered a problem using the Chicken Scheme Compiler that I have trouble understanding. When I use (declare (fixnum-arithmetic)), literal values that are (expt 2 30) or over but within the fixnum 64-bit range cause the following error:
Error: cannot coerce inexact literal `2166136261' to fixnum
What is stranger is that printing the most-positive-fixnum value from (import (chicken fixnum)) works fine and is a value way larger than 230.
I included the various tests I performed. Uncomment the relevant parts for one particular test, the results I got are included after each test:
;File: test-chicken.scm (declare (fixnum-arithmetic)) ;; always there for all tests ;(import (chicken fixnum)) ;(display most-positive-fixnum) ;;; works fine, prints 4611686018427387903 ;(display (exact? 1073741824)) ;;; works fine, prints #t ;(display 1073741824) ;;; craches with Error: cannot coerce inexact literal `1073741824' to fixnum ;(display 1073741824) ;;; works fine, prints 1073741824
I compiled and ran the tests using the following command: csc test-chicken.scm -o test-chick && ./test-chick
For context, I found this bug working on Ribbit, another scheme implementation because of the inclusion of the literal for a hash function: https://github.com/udem-dlteam/ribbit/blob/7666b6c017a73a0a82e8df7f9de119d2408da404/src/rsc.scm#L1035
Here are infos about my csc version:
> csc -version CHICKEN (c) 2008-2022, The CHICKEN Team (c) 2000-2007, Felix L. Winkelmann Version 5.4.0 (rev 1a1d1495) macosx-unix-clang-arm64 [ 64bit dload ptables ]
