Deleting un(?)reachable code



Does anyone have any idea why sbcl would delete these
code segments? There are three FORMAT forms and one
CDR form.

The FORMATs occur in an inlined function (USABLE), and are
called conditionally, depending on the value of an optional arg
(TESTING). I understand that the conditional calls can be elim-
inated for any call to the inline function that doesn't specify
a value for the condition, which defaults to nil. But there's
still some strangeness left over:

1. Why does the compiler single out the format strings as
being the unreachable part?
2. Why aren't the PAUSE forms eliminated, since they're in
the same WHEN forms as the FORMATs?
3. Why is the (cdr cell) form that's called inside the
(while (cdr cell) ...) form eliminated? An obvious thought
would be that I got the test backwards in WHILE, but it's tested
and seems to work. The conditional test in WHILE is
(unless ,test (return-from ,block))
I don't see how that could be wrong.

(compiler output & code snippets below;
affected code is under-careted)

--Dan

Compiler output:

; in: DEF-INLINE USABLE
; (FORMAT T "n-div = ~D. " PANPAL::N-DIV)
; ==> "n-div = ~D. "
; note: deleting unreachable code
; (FORMAT T "~A is usable.~%" PANPAL::WORD)
; ==> "~A is usable.~%"
; note: deleting unreachable code
; (FORMAT T "~A is not usable.~%" PANPAL::WORD)
; ==> "~A is not usable.~%"
; note: deleting unreachable code

; in: DEF TRIM-WORDS
; (CDR PANPAL::CELL)
; ==> PANPAL::CELL
; note: deleting unreachable code

Code snippets:

(def-inline usable (word fortree baktree &optional verbose)
...
(dotimes (n-div (1- num-chars))
(when verbose
(format t "n-div = ~D. " n-div)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(pause "try-subs<RTRN>"))
(when (try-subs n-div)
(when verbose
(format t "~A is usable.~%" word)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(pause "return-from usable."))
(return-from usable t)))
(when verbose
(format t "~A is not usable.~%" word)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(pause "End usable."))
nil)))

....
(while (cdr cell)
(let* ((wrd (cadr cell))
(ok (usable wrd fortree baktree)))
(cond
(ok (setf cell (cdr cell))) ;move down the list
^^^^^^^^^^
(t (setf (cdr cell) (cddr cell)) ;delete the wrd
(delete-wrd wrd fortree baktree)))))

------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/
.



Relevant Pages

  • Re: Deleting un(?)reachable code
    ... CDR form. ... Usually when I get these "deleting unreachable code" errors its because I did something stupid, generally rather far from the code which is flagged. ... Why does the compiler single out the format strings as ...
    (comp.lang.lisp)
  • Re: Format not an option for D:
    ... you don't format CD-R media. ... you still would rarely format a CDR for usage. ... Associate Expert - WindowsXP Expert Zone ...
    (microsoft.public.windowsxp.general)
  • Re: corel files cdr and cmx and thumbnails in it
    ... Ppl say that .cdr is proprietary format so i am not sure if ... small pices of code by ppl in theme of reading cmx but it has not ... (speakin about .cdr ... 256 color bitmap with about 14 bytes of headrer "damaged" ...
    (comp.programming)
  • Re: Win2k and CDRs
    ... UDF format, you will ... >need a UDF reader installed on your PC (or on every CDRW ... The problem exists with either CDR or CDRWs. ... Further, the installation of Win2K is virgin, that is ...
    (microsoft.public.win2000.hardware)
  • Re: Tar output mode for installworld
    ... a description of the final archive in a nice verbose ... use of a modified mtree format as the specification format: ... the regular install process could install ...
    (freebsd-hackers)