Bug #454681 reported by Tobias C. Rittweiler on 2009-10-18
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

(defun test ()
  (let* ((*sequence* '#*0000000000)
         (*size* 10)
         (*start* 1)
         (*end* (1- *size*))
         (*from-end* t))
    (let ((result
           (sb-sequence:make-sequence-like *sequence*
                                           (- (or *end* *size*) (or *start* 0)))))
      (multiple-value-bind (iterator+977 getter+978 setter+979)
          (tcr.sequence-iterators::%make-sequence-iterator *sequence*
                                                           :start *start*
                                                           :end *end*
                                                           :from-end *from-end*)

        (declare (ignorable iterator+977 setter+979 getter+978))
        (flet ((iterator+976 ()
                 (funcall iterator+977))
               (ptr ()
                 (funcall getter+978))
               ((setf ptr) (new-value)
                 (funcall setter+979 new-value)))
          (declare (ignorable (function iterator+976) (function (setf ptr))
                              (function ptr)))
          (declare (inline iterator+976 ptr (setf ptr)))
          (let ((iterator+976 #'iterator+976))
            (declare (ignorable iterator+976))
            (prog ((iterator+1002 iterator+976) (elt) (idx+1005) (next?+1003))
               (let (tmp-var+1006 tmp-idx+1007)
                 (multiple-value-setq (next?+1003 tmp-var+1006 tmp-idx+1007)
                   (funcall iterator+1002))
                 (unless next?+1003 (return result))
                 (setq elt tmp-var+1006)
                 (setq idx+1005 tmp-idx+1007))
               (setf (elt result idx) elt)
               (incf idx)
               (go [do-sequence-iterators*]-loop+1004))))))))

Changed in sbcl:
status: New → Confirmed
importance: Undecided → Medium
importance: Medium → High
Nikodemus Siivola (nikodemus) wrote :

Reduced test case:

(defun test ()
  ;; If there is only a single value here, the code compiles fine.
  (multiple-value-bind (iterator+977 getter+978) (DOES-NOT-EXIST-BUT-DOES-NOT-MATTER)
    (flet ((iterator+976 ()
             (funcall iterator+977)))
      ;; If the inline declaration is missing, the code compiles fine.
      (declare (inline iterator+976))
      (let ((iterator+976 #'iterator+976))
        ;; If the call is to the function and not the variable, the code compiles fine.
        (funcall iterator+976)))))

tags: added: compiler
Alexey Dejneka (adejneka) wrote :

Inline expansion of ITERATOR+976 tries to refer to a dead LAMBDA-VAR ITERATOR+977 of varargs entry, which was substituted with ITERATOR+977 of &OPTIONAL processor. Thus the referenced variable is dead and is not bound anywhere.

The attached patch fixes the problem by giving up on inline expansion if it tries to make a reference to a dead LAMBDA-VAR, similar to the way dead BLOCK tags are treated.

Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
status: Confirmed → In Progress
Nikodemus Siivola (nikodemus) wrote :


Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
status: In Progress → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers