Greetings, and thanks so much for the report!  This is "fixed" now in
master.

GCL's compiler makes pretty heavy use of elimination of calls to 'list
and friends when it is used as a temporary vessel for desired computed
values and those values can be obtained elsewhere.  One can imagine the
utility of this in limiting consing, especially when inlining nested lisp
code.  To do this it tracks each cons through aliasing in variables
etc. and replaces (car l) etc. with its value when possible.  If no more
references to the list remain it can be eliminated as an ignorable form.
Unfortunately, this alias tracking does not (yet) proceed through
arrays, structures, hash-tables, etc.

The relevant lines of sort (now) are

    (when list
      (do ((fi 0 (1+ fi)) (l seq (cdr l))) ((>= fi ll)) (setf (aref a fi) l)))
    (do ((ii (list ll 0))) ((not ii) (if a (aref a 0) seq)); or could "spoil" 
(car l) above

where (if a (aref a 0) seq) used to be just seq.  Alternatively one
could "spoil" the car's of seq by replacing (setf (aref a fi) l) with
(setf (aref a fi) l (car l) (car l)).  But the point is that alas this
is a workaround to a compiler weakness at present, and a user could in
principle write equivalent code elsewhere.

Now if some kind friend of GCL could just turn their Claude engine to
discover why GCL's self bootstrap build is not yet Debian reproducible
even when limited to one make job, that would be most helpful!  I have
another 6 months or so to figure this one out.

Take care,

Raymond Toy <[email protected]> writes:

> While working on some things in maxima, I found that gcl was incorrectly 
> computing some numerical results. With help from Claude, it was
> isolated to a bug in sort.
>
> Load the attached file to see the issue. I’m using gcl (that I compiled 
> myself):
>
>>(lisp-implementation-version)
>
> "GCL 2.7.1 git tag Version_2_7_2pre15"
>
> I get:
>
>> (load "gcl-sort-bug.lisp")
> ...
> direct-gf  (1.0 2.0 3.0)
> dbind-cl   (2.0 1.0 3.0)  <-- expected (1.0 2.0 3.0)
> dbind-fun  (2.0 1.0 3.0)  <-- expected (1.0 2.0 3.0)
> dbind-gf   (2.0 1.0 3.0)  <-- expected (1.0 2.0 3.0)
> setf-cl    (2.0 1.0 3.0)  <-- expected (1.0 2.0 3.0)
> setf-fun   (2.0 1.0 3.0)  <-- expected (1.0 2.0 3.0)
> setf-gf    (2.0 1.0 3.0)  <-- expected (1.0 2.0 3.0)
> vector-gf  (1.0 2.0 3.0)
> 6 of 10 failed
> ;; Finished loading "gcl-sort-bug"
> &#8203;
>
>

-- 
Camm Maguire                                        [email protected]
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah

Reply via email to