[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] #823: arithmetic-shift fails in exactly one edge case
From: |
Chicken Trac |
Subject: |
[Chicken-janitors] #823: arithmetic-shift fails in exactly one edge case |
Date: |
Fri, 04 May 2012 12:58:01 -0000 |
#823: arithmetic-shift fails in exactly one edge case
-----------------------------------------------------+----------------------
Reporter: sjamaan | Owner:
Type: defect | Status: new
Priority: minor | Milestone: 4.9.0
Component: core libraries | Version: 4.7.x
Keywords: edge cases, numbers, shifting, overflow |
-----------------------------------------------------+----------------------
I don't know whether it's worth the trouble to fix this, but I'll put it
on here so at least it's documented.
{{{(arithmetic-shift -123 most-negative-fixnum) => -123}}}
This should be {{{-1}}}. It fails because in chicken.h the
{{{C_i_fixnum_arithmetic_shift}}} function calls
{{{C_fixnum_shift_right}}} with the negated value of the shift amount.
This overflows and wraps around to zero.
Fixing it would be simplest by just inlining the shift and negating
_after_ unboxing. This is easy, but there are some other places that call
{{{C_fixnum_shift_right}}} in this way.
This code is obviously wrong but I'm not sure it's worth fixing, since
it's such an extreme edge case (if you subtract 1 from the shift amount
you get an error that the argument is not a fixnum). On the other hand,
not fixing it just seems, I dunno... lazy and possibly dangerous. :)
--
Ticket URL: <http://bugs.call-cc.org/ticket/823>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Chicken-janitors] #823: arithmetic-shift fails in exactly one edge case,
Chicken Trac <=