pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg/43609: hugs98 overflow bug when printing Integers on platforms with sizeof(long) != sizeof(int)
>Number: 43609
>Category: pkg
>Synopsis: hugs98 overflow bug when printing Integers on platforms with
>sizeof(long) != sizeof(int)
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 13 06:25:00 +0000 2010
>Originator: Matthias Kretschmer
>Release: NetBSD 5.0.2_PATCH
>Organization:
>Environment:
NetBSD random87 5.0.2 NetBSD 5.0.2 (GENERIC) amd64
>Description:
If you convert Int to Integer using toInteger, then there is a sign extension
bug in the underlying primitive. This is only triggered on platforms with
sizeof(long)==8 > sizeof(int)==4.
If you have the sign extension bug, then toInteger (minBound :: Int), toInteger
(minBound :: Data.Int.Int32), etc. return false results.
>How-To-Repeat:
compile hugs98 on amd64 or any other LP64 platform and do the following in the
interpreter:
Hugs> toInteger (minBound :: Int)
-18446744071562067968
where as it should read
Hugs> toInteger (minBound :: Int)
-2147483648
>Fix:
Changing src/bignums.c line 120 from
no = (unsigned long)(-n);
to
no = (unsigned long)(-(long)n);
solves the problem.
Home |
Main Index |
Thread Index |
Old Index