#1011 closed defect (invalid)
float and double foreign-lambdas return wrong values
Reported by: | Shawn Rutledge | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | someday |
Component: | unknown | Version: | 4.8.x |
Keywords: | Cc: | ||
Estimated difficulty: |
Description
Sometimes I've had better luck with double, but now I wrote an egg just to demonstrate this, and it's failing pretty consistently for both float and double, at least for me, on 64-bit Arch Linux.
Version 4.8.0.3 (stability/4.8.0) (rev 091c3d9)
#;1> (use getafloat)
; loading /usr/lib/chicken/6/getafloat.import.so ...
; loading /usr/lib/chicken/6/getafloat.so ...
#;2> (get-float)
get_float returning 1368477568.000000
38.0
#;3> (get-double)
get_float returning 1368477622.402598
38.0
#;4> (get-int)
5
#;5> (get-pair)
get_float returning 1368477696.000000
get_float returning 1368477696.000000
(38.0 . 38.0)
Attachments (1)
Change History (3)
Changed 11 years ago by
Attachment: | getafloat.tgz added |
---|
comment:1 Changed 11 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
The solution is to declare the C function prototypes, e.g. declare them in a header and include it in the scm, or declare them inline. Despite the fact that the foreign-lambda looks like it declares the signature, chicken still assumes the return value will be an int unless it has the C function prototype. (This is still a bit of an annoyance, IMO.)
(module getafloat * (import ...) #> #include "impl.h" <# ... )
See also https://lists.gnu.org/archive/html/chicken-users/2013-05/msg00045.html
egg to demonstrate the bug