chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Fix a few more mistakes in types.db


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Fix a few more mistakes in types.db
Date: Sun, 11 Mar 2012 21:05:28 +0100
User-agent: Mutt/1.4.2.3i

Hi there,

I found a bug in the specialization for the ROUND procedure; the
specialization calls C_a_i_flonum_round while it should call
C_a_i_flonum_round_proper.  This results in a difference when the
following program is interpreted versus when it is compiled with
various levels of optimization:

(print (round 4.5)) ;; 5.0 when compiled with -O3 or higher, 4.0 otherwise

The correct answer is 4.0 since R5RS says round needs to round to the
nearest even number when the number is halfway between two integers.

I added a test for this to library-tests.scm, but figured out that
it wasn't compiled at all, which is why this bug wasn't caught by
"make check".  Since the library is large and has many specializations,
it makes sense to compile the library test.  As we add more tests, these
will automatically test any additional specializations.

After making it compile, I found several more mistakes which I've also
fixed in this patch.

By the way, I don't understand why the continuation test at the end
used to work; when compiled it complains the second time it calls
(k #f) that k is false, which I'd expect.  Can someone explain why
this isn't the case in interpreted mode?

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: 0001-Ensure-library-tests-are-compiled-to-catch-specializ.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]