[Ecls-list] BUG: LDB returning incorrect results in compiled code

Juan Jose Garcia-Ripoll jjgarcia at users.sourceforge.net
Mon Oct 1 10:51:49 UTC 2007


2007/9/30, Eric Marsden <eric.marsden at free.fr>:
> LDB returns incorrect results in compiled code when the bytespec is
> more than 32 bits wide.
>
> ,----
> | CL-TEST> (ldb (byte 27 5) -1)
> | 134217727
> | CL-TEST> (funcall (compile nil (lambda () (ldb (byte 27 5) -1))))
> | -1
> `----

Hi Eric, do you have any special optimization settings? I do not have
this problem with a recently built version (see below) As shown below
the code is pretty harmless: it just calls the full functions (BYTE
and LDB), without any further optimization. Can you please post the
code of DISASSEMBLE in your system? I currently do not have access to
a 64bit machine.

Juanjo


> (funcall (compile nil '(lambda () (ldb (byte 27 5) -1))))
[...]
134217727
> (funcall (compile nil '(lambda () (declare (optimize (speed 0))) (ldb (byte 27 5) -1))))
[...]
134217727
> (funcall (compile nil '(lambda () (declare (optimize (speed 0) (safety 0))) (ldb (byte 27 5) -1))))
[...]
134217727
> (funcall (compile nil '(lambda () (declare (optimize (speed 3) (safety 0))) (ldb (byte 27 5) -1))))
[...]
134217727
> (funcall (compile nil '(lambda () (ldb (byte 27 5) -1))))
[...]
;;; OPTIMIZE levels: Safety=0, Space=0, Speed=3
134217727
> (disassemble '(lambda () (ldb (byte 27 5) -1)))
;;; Compiling (DEFUN C::GAZONK ...).
;;; Emitting code for C::GAZONK.

/*	function definition for GAZONK                                */
static cl_object L1c__gazonk()
{ VT2 VLEX2 CLSR2
	cl_object value0;
TTL:
	T0= cl_byte(2,MAKE_FIXNUM(27),MAKE_FIXNUM(5)) /*  BYTE        */;
	value0=cl_ldb(2,T0,MAKE_FIXNUM(-1))       /*  LDB             */;
	return value0;
}
NIL
-- 
Facultad de Fisicas, Universidad Complutense,
Ciudad Universitaria s/n Madrid 28040 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list