Hi all,

To mention the easy bug first, and jumping right into the thick of it, CIRCULAR-LIST-ERROR quite clearly binds *PRINT-CIRCLE* to T right before invoking ERROR, but it gets either reset or rebound to NIL somewhere before INVOKE-DEBUGGER.  Example:

* (sb-impl::CIRCULAR-LIST-ERROR '#1=(FOOL HI WHAT IS THIS . #1#))
debugger invoked on a SIMPLE-TYPE-ERROR:
  List is circular:
  (FOOL HI WHAT IS THIS FOOL HI WHAT IS THIS FOOL HI ...)

Ok, so that's irrelevant, but ... another reason that we hand-roll FIND is that the builtin isn't able to eliminate the unused 'index' variable.  It's easy to show that this has nothing to do with a multiple-value-bind of both the element and its index and using only either the former or latter  from %find-position-if.   In this minimal example:
(defun foofind (item list)
  (declare (optimize (speed 3) (safety 0)))
  (let ((ind 0))
    (declare (fixnum ind))
    (dolist (x list)
      (when (eq x item) (return x))
      (incf ind))))

The compiler is maintaining RDX inside the loop as shown in this disassembly fragment:
; disassembly for FOOFIND
[...elided...]
;       B0: L0:   488B59F9         MOV RBX, [RCX-7]
;       B4:       488B4901         MOV RCX, [RCX+1]
;       B8:       4839F3           CMP RBX, RSI
;       BB:       7418             JEQ L3
;       BD:       4883C202         ADD RDX, 2

My understanding having read Paul's blog entry titled "fixed-points-and-strike-mandates" was that SBCL does use the non-naive approach of assuming that variables are dead until proven live, rather than live until proven dead; and therefore that it should be able to prove that 'ind' is effectively dead because its value is used only to compute "another" dead variable, namely, itself.

Is there an open bug with say 'wishlist' status for this already?  I didn't see one.
Regards

-d