[Ecls-list] Internal unused variable leaking through

Tobias C. Rittweiler tcr at freebits.de
Sun Feb 7 00:04:24 UTC 2010


"Tobias C. Rittweiler" writes:

> ;;; /tmp/frob.lisp
>
> (defun import-from (package symbol-names &optional (to-package *package*))
>   "Import the list of SYMBOL-NAMES found in the package PACKAGE."
>   (dolist (name symbol-names)
>     (multiple-value-bind (symbol found) (find-symbol (string name) package)
>       (assert found () "Symbol ~A not found in package ~A" name package)
>       (import symbol to-package))))
>
>
> CL-USER> (compile-file "/tmp/frob.lisp")
> ;;; Compiling /tmp/frob.lisp.
> ;;; OPTIMIZE levels: Safety=3, Space=0, Speed=1, Debug=3
> ;;; Compiling (DEFUN IMPORT-FROM ...).
> ;;; Note: in file /tmp/frob.lisp, position 0, and form 
> ;;;   (FSET 'IMPORT-FROM #'(LAMBDA-BLOCK IMPORT-FROM # ...))
> ;;; Removing unused variable G14
> ;;; End of Pass 1.
> ;;; Emitting code for IMPORT-FROM.
> ;;; Emitting code for #:G12.
> ;;; Emitting code for #:G13.
> ;;; Note: Invoking external command:
> ;;;   gcc "-I/home/tcr/software/ecl-git/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -D_THREAD_SAFE -Dlinux  -w -c "/tmp/frob.c" -o "/tmp/frob.o"
> ;;; Note: Invoking external command:
> ;;;   gcc -o "/tmp/frob.fas" -L"/home/tcr/software/ecl-git/lib/" "/tmp/frob.o"   -shared    -lecl  -lgmp -lpthread -ldl  -lm 
> ;;; Finished compiling /tmp/frob.lisp.
>
>
> The note regarding "Removing unused variable G14" seems to come from
> internal code.


Here is another example where internal variable usage leaks through:


(defvar *thread-id-counter* 0)

(defvar *thread-id-counter-lock*
  (mp:make-lock :name "thread id counter lock"))

(defun next-thread-id ()
  (mp:with-lock (*thread-id-counter-lock*)
    (incf *thread-id-counter*)))

;;; Compiling /tmp/frob.lisp.
;;; OPTIMIZE levels: Safety=3, Space=0, Speed=1, Debug=3
;;; Compiling (DEFVAR *THREAD-ID-COUNTER* ...).
;;; Compiling (DEFVAR *THREAD-ID-COUNTER-LOCK* ...).
;;; Compiling (DEFUN NEXT-THREAD-ID ...).
;;; Variable *ALLOW-WITH-INTERRUPTS* was undefined. Compiler assumes it is a global.
;;; Note: in file /tmp/frob.lisp, position 114, and form 
;;;   (FSET 'NEXT-THREAD-ID #'(LAMBDA-BLOCK NEXT-THREAD-ID NIL ...))
;;; Removing unused variable OUTER-ALLOW-WITH-INTERRUPTS-8
;;; Note: in file /tmp/frob.lisp, position 114, and form 
;;;   (FSET 'NEXT-THREAD-ID #'(LAMBDA-BLOCK NEXT-THREAD-ID NIL ...))
;;; Removing unused variable *ALLOW-WITH-INTERRUPTS*
;;; End of Pass 1.
;;; Emitting code for NEXT-THREAD-ID.
;;; Note: Invoking external command:
;;;   gcc "-I/home/tcr/software/ecl-git/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -D_THREAD_SAFE -Dlinux  -w -c "/tmp/frob.c" -o "/tmp/frob.o"
;;; Note: Invoking external command:
;;;   gcc -o "/tmp/frob.fas" -L"/home/tcr/software/ecl-git/lib/" "/tmp/frob.o"   -shared    -lecl  -lgmp -lpthread -ldl  -lm 
;;; Finished compiling /tmp/frob.lisp.

  -T.





More information about the ecl-devel mailing list