Subject: [clisp-list] bug with logtest

From: Russ Ross <[email-masked]>
Date: Tue Aug 12 16:18:02 2003

I'm having problems with logtest.  For a test of the form
(logtest (ash 1 n) (ash 1 n))
I'd expect a result of T for any n, but I don't always get that:

(logtest (ash 1 23) (ash 1 23)) gives me T
(logtest (ash 1 24) (ash 1 24)) gives me NIL
(logtest (ash 1 63) (ash 1 63)) gives me NIL
(logtest (ash 1 64) (ash 1 64)) gives me T
(logtest (ash 1 100) (ash 1 100)) gives me T

It goes back and forth several times as the following demonstrates:

(do ((x 0 (+ x 1)))
    ((eq x 200))
    (print x)
    (print (logtest (ash 1 x) (ash 1 x))))

It alternates between ranges of T and NIL output.

So it seems there is a bug in logtest for certain sizes of integers.

I tested with a fresh build.  Here's my system info:

$ uname -a
Linux boulderdash.cl.cam.ac.uk 2.4.19-2cl-ext3 #1 SMP Thu Oct 24
10:18:47 BST 2002 i686 i686 i386 GNU/Linux

I got the sources from the links on clisp.org on 2003-08-11.

I built it using:

$ ./configure --prefix=/home/rgr22/clisp
$ ./makemake --with-dynamic-ffi  --prefix=/home/rgr22/clisp   >
Makefile
$ make config.lisp
$ vim config.lisp (I changed the default editor from vi to vim)
$ make
$ make check
$ make install

make install had some problems because the symlinks in the "full"
directory weren't right.  I fixed those and repeated the "make
install" step.

$ clisp --version
GNU CLISP 2.30 (released 2002-09-15) (built 3269712794) (memory
3269712892)
Features:
(CLOS LOOP COMPILER CLISP ANSI-CL COMMON-LISP LISP=CL INTERPRETER
SOCKETS
 GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN FFI UNICODE
BASE-CHAR=CHARACTER PC386
 UNIX)

Thanks,

Russ Ross

---

From: Sam Steingold <[email-masked]>
Date: Wed Aug 13 07:46:02 2003

> * In message <[email-masked]>
> * On the subject of "bug with logtest"
> * Sent on Wed, 13 Aug 2003 00:16:46 +0100
> * Honorable Russ Ross <[email-masked]> writes:
>

apparently the assembly code in ari80386.d (and_test_loop_up) is broken:

# extern bool and_test_loop_up (uintD* xptr, uintD* yptr, uintC count);
            ALIGN
C(and_test_loop_up:)
            pushl   %esi            # %esi retten
            movl    8(%esp),%edx    # %edx = xptr
            movl    12(%esp),%esi   # %esi = yptr
            movl    16(%esp),%ecx   # %ecx = count
            jecxz   L(atlu2)        # %ecx = 0 ?
            subl    %edx,%esi
L(atlu1:)     movl    (%edx,%esi),%eax # *yptr
              andl    (%edx),%eax      # *xptr & ...
              jnz     L(atlu3)
              leal    4(%edx),%edx     # xptr++, yptr++
              decl    %ecx
              jnz     L(atlu1)
L(atlu2:)   xorl    %eax,%eax       # Ergebnis 0
L(atlu3:)   popl    %esi            # %esi zurück
            ret

since I don't know assembly at all, I can only hope that someone will
step up to fix this.

(define NO_ASM in lispbibl.d and the assembly is ignored and everything
works correctly)

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Failure is not an option. It comes bundled with your Microsoft product.