Fixes <http://bugs.gnu.org/14864>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/vm-i-scheme.c (ash): Fallback to 'scm_ash' for right shifts
with counts >= SCM_I_FIXNUM_BIT, since '>>' is not guaranteed to work
correctly for large counts.
if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
{
if (SCM_I_INUM (y) < 0)
- /* Right shift, will be a fixnum. */
- RETURN (SCM_I_MAKINUM (SCM_I_INUM (x) >> -SCM_I_INUM (y)));
+ {
+ /* Right shift, will be a fixnum. */
+ if (SCM_I_INUM (y) > -SCM_I_FIXNUM_BIT)
+ RETURN (SCM_I_MAKINUM (SCM_I_INUM (x) >> -SCM_I_INUM (y)));
+ /* fall through */
+ }
else
/* Left shift. See comments in scm_ash. */
{