odd code deletion note from lambda as argument to a load-time function call

Bug #491256 reported by Tobias C. Rittweiler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Low
Douglas Katzman

Bug Description

(defvar *foo*)
(defun bar (f)
  (setf *foo* f))
(bar (formatter "~A"))

; compiling file "/tmp/foo.lisp" (written 02 DEC 2009 09:22:50 AM):

; file: /tmp/foo.lisp
; in: BAR (FORMATTER "~A")
; (BAR (FORMATTER "~A"))
;
; note: deleting unreachable code
;
; compilation unit finished
; printed 1 note

; /tmp/foo.fasl written
; compilation finished in 0:00:00.009

Revision history for this message
Tobias C. Rittweiler (tcr) wrote : Re: FORMATTER + toplevel function call, unreachable code

Must have something to do with the way the FOP compiler arranges
toplevel calls?

  (defvar *foo*)
  (defun bar (f)
    (setf *foo* f))
  (unless *foo* (bar (formatter "~A"))) ;;; => no note

summary: - FORMATTER + function call, unreachable code
+ FORMATTER + toplevel function call, unreachable code
Revision history for this message
Nikodemus Siivola (nikodemus) wrote : Re: [Bug 491256] [NEW] FORMATTER + function call, unreachable code

 status confirmed
 importance low
 summary "odd code deletion note from lambda as argument to a load-time function call"

This makes the issue more apparent:

(defvar *foo*)
(defun bar (f)
 (setf *foo* f))
;; LET means this isn't toplevel code
(let ()
 (bar
  (LAMBDA
       (STREAM
        &OPTIONAL
        (FORMAT-ARG1010
         (ERROR 'SB-FORMAT:FORMAT-ERROR :COMPLAINT "required argument missing"
                :CONTROL-STRING "~A" :OFFSET 1))
        &REST SB-FORMAT::ARGS)
     (DECLARE (IGNORABLE STREAM))
     (BLOCK NIL (PRINC FORMAT-ARG1010 STREAM))
     SB-FORMAT::ARGS))

gives

  note:
    deleting unreachable code
    --> LET SB-C::%FUNCALL
    ==>
      STREAM

  note: deleting unreachable code

but

(defun foo ()
  (bar
   (LAMBDA
       (STREAM
        &OPTIONAL
        (FORMAT-ARG1010
         (ERROR 'SB-FORMAT:FORMAT-ERROR :COMPLAINT "required argument missing"
                :CONTROL-STRING "~A" :OFFSET 1))
        &REST SB-FORMAT::ARGS)
     (BLOCK NIL (PRINC FORMAT-ARG1010 STREAM))
     SB-FORMAT::ARGS)))

is silent. (Both under COMPILE-FILE.)

summary: - FORMATTER + toplevel function call, unreachable code
+ odd code deletion note from lambda as argument to a load-time function
+ call
Changed in sbcl:
importance: Undecided → Low
status: New → Confirmed
Stas Boukarev (stassats)
tags: added: deletion-note
Revision history for this message
Douglas Katzman (dougk) wrote :

Fixed. Test case is :dead-code-in-optional-dispatch in compiler.pure.lisp

Changed in sbcl:
assignee: nobody → Douglas Katzman (dougk)
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.