On 10/24/26 5:15 AM, Camm Maguire wrote:

Greetings, and thanks so much for the report!  This is "fixed" now in
master.
Thanks for the quick fix! Also, it’s a regression. 2.6.14 doesn’t have this problem. And finally, using stable-sort doesn’t have this problem either in 2.7.2.
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.
I could help, but I’d need lots of guidance on what to look for.

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;


&#8203;

Reply via email to