emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47080: closed (28.0.50; Spurious variable left uninitialized compile


From: GNU bug Tracking System
Subject: bug#47080: closed (28.0.50; Spurious variable left uninitialized compiler warning)
Date: Fri, 12 Mar 2021 03:30:02 +0000

Your message dated Thu, 11 Mar 2021 22:29:08 -0500
with message-id <jwv7dmdhxd8.fsf-monnier+emacs@gnu.org>
and subject line Re: bug#47080: 28.0.50; Spurious variable left uninitialized 
compiler warning
has caused the debbugs.gnu.org bug report #47080,
regarding 28.0.50; Spurious variable left uninitialized compiler warning
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
47080: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=47080
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: 28.0.50; Spurious variable left uninitialized compiler warning Date: Fri, 12 Mar 2021 01:04:14 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Hello,

here is the test case:

#+begin_src emacs-lisp
;; -*- lexical-binding: t -*-

(require 'pcase)
(require 'find-func) ;not involved AFAICT, just funs used in example

(defun my-find-function (function)
  (interactive (find-function-read))
  (pcase (find-function-library function)
    ((or 'nil
         (and `(,_ . ,file) (guard (or (not (stringp file)) (string-match-p 
"\\.c$" file))))
         (guard (not (find-definition-noselect function nil))))
     (describe-function function))))
#+end_src

Compiling gives me:

| compile-test.el:6:1: Warning: Variable `file' left uninitialized
| compile-test.el:6:1: Warning: Variable `file' left uninitialized

TIA,

Michael.


In GNU Emacs 28.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo 
version 1.16.0)
 of 2021-03-12 built on drachen
Repository revision: 69b952bcac5366df4cd37a7681318b29bc23e3c8
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: Debian GNU/Linux bullseye/sid

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SOUND
THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB




--- End Message ---
--- Begin Message --- Subject: Re: bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning Date: Thu, 11 Mar 2021 22:29:08 -0500 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Lars Ingebrigtsen [2021-03-12 04:07:47] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Indeed, it's a useless binding: you could just use nil instead wherever
>> you use that var, so the warning is working as intended.  And indeed, it
>> found a few places where we bound a var to nil and then just
>> returned its value (and it's thanks to this warning that I discovered
>> that those var needed to be declared as dynamically scoped).
>
> Oh, is that what the warning means.  :-)  It's not immediately
> obvious -- could it be changed to something like...  er...  "Variable
> bound to constant value and not changed"?

Indeed, the warning could even be generalized to other trivial constant
values like `t`, but I think what we have already gives enough false
positives ;-)
[ Still, I'm quite happy with the warning in that it pointed me to a few
  actual problems in the code.  The average usefulness rating of each
  of the warnings that I fixed after adding this warning was not too bad.  ]

As for changing the wording, feel free: I'm not too happy with the
current one either (after all, the variables are initialized to nil in
any case, so there's no such thing as an uninitialized variable),
tho I'm not very fond of the one you suggest.

In any case I installed the patch below which should fix the immediate 
offenders.


        Stefan


diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index ca641a2ef0..cfb0168a6e 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -602,7 +602,8 @@ cconv--analyze-use
      (byte-compile-warn
       "%s `%S' not left unused" varkind var))
     ((and (let (or 'let* 'let) (car form))
-          `(,(or `(,var) `(,var nil)) t nil ,_ ,_))
+          `(,`(,var) ;; (or `(,var nil) : Too many false positives: bug#47080
+            t nil ,_ ,_))
      ;; FIXME: Convert this warning to use `macroexp--warn-wrap'
      ;; so as to give better position information.
      (unless (not (intern-soft var))



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]