Subject: Re: bug#36740: 27.0.50; apparently buggy code in ccl.c (lookup-integer-constant)

From: Andy Moreton <[email-masked]>
Date: Sat, 20 Jul 2019 23:48:30 +0100

On Sat 20 Jul 2019, Pip Cet wrote:

> On Sat, Jul 20, 2019 at 7:00 PM Andy Moreton <[email-masked]> wrote:
>> > Patch attached. It'd be nice to have tests for this, of course, but
>> > it'd be easier for someone who understands CCL to do...
>>
>> Are the tests in test/lisp/international/ccl-tests.el sufficient ? If
>> not, please etend them to cover this case.
>
> I'm trying, but it seems like the CCL code is somewhat broken:
> `ccl-embed-symbol', as it is now, can never succeed, because it passes
> a cons cell rather than a fixnum to (ultimately) logand.

Agreed - probably my fault when fixing this code up to prepare for
bignum support.

>  (defun ccl-fixnum (code)
>    "Convert a CCL code word to a fixnum value."
> -  (- (logxor (logand code #x0fffffff) #x08000000) #x08000000))
> +  (if (integerp code)
> +      (- (logxor (logand code #x0fffffff) #x08000000) #x08000000)
> +    code))

`ccl-fixnum' should only receive integer arguments, so perhaps this fix
should go in the call in `ccl-embed-data' instead:

    (aset ccl-program-vector ccl-current-ic
      (if (numberp data) (ccl-fixnum data) data))

Thanks,

    AndyM