From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning Date: Thu, 11 Mar 2021 22:29:08 -0500 Message-ID: References: <87tuph6xvl.fsf@web.de> <875z1xz0d6.fsf@gnus.org> <87lfatul18.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24271"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Michael Heerdegen , 47080-done@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 12 04:30:18 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lKYVG-0006EH-DS for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Mar 2021 04:30:18 +0100 Original-Received: from localhost ([::1]:36250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKYVC-0002Hb-Qe for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Mar 2021 22:30:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKYV0-0002Gm-T5 for bug-gnu-emacs@gnu.org; Thu, 11 Mar 2021 22:30:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44224) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKYV0-0002W9-JT for bug-gnu-emacs@gnu.org; Thu, 11 Mar 2021 22:30:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lKYV0-0007L0-Ga for bug-gnu-emacs@gnu.org; Thu, 11 Mar 2021 22:30:02 -0500 Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Mar 2021 03:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 47080 X-GNU-PR-Package: emacs Mail-Followup-To: 47080@debbugs.gnu.org, monnier@iro.umontreal.ca, michael_heerdegen@web.de Original-Received: via spool by 47080-done@debbugs.gnu.org id=D47080.161551975928128 (code D ref 47080); Fri, 12 Mar 2021 03:30:02 +0000 Original-Received: (at 47080-done) by debbugs.gnu.org; 12 Mar 2021 03:29:19 +0000 Original-Received: from localhost ([127.0.0.1]:55768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKYUI-0007Jb-Ol for submit@debbugs.gnu.org; Thu, 11 Mar 2021 22:29:18 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:32875) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKYUH-0007JN-33 for 47080-done@debbugs.gnu.org; Thu, 11 Mar 2021 22:29:17 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 918CC10023D; Thu, 11 Mar 2021 22:29:11 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 278221001D2; Thu, 11 Mar 2021 22:29:10 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1615519750; bh=TkRYBPhz3cSlaTd//t/C+NtA6Ls/soFQt/zG/TCb9QI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=FsXXS+6ik5wxy9kWa0MJ/ld7Pwt2KSVM77MsipP48JG68OrCNM8LWks2vPsBHs3DA oFF2QC7/cSULRtPdd6SbZlKup7upu0BqamVvuGpUIxmeh9xth5+p510Gv3phiNzgaw xQpkQfj9AwvzjRsKbQBNmyWsp0ARkczyrU/QTrUotlEtfzmRV5YMul3lvSnEntdvlA DULyJ6wOK5QgwKwhBzgjAwIeyuBjPUpDRuvD4UcKJ/+fo7OCnpMgQeE2dtYYYT+bfA gGqL4a9SP8DWreAnDzHAvI89MZFCo3lJL4XNaz4whvvN1Unb4Hv08JzSEn5DmKVSjb CHnQ0QraLmcaA== Original-Received: from alfajor (unknown [216.154.43.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D1C661203A2; Thu, 11 Mar 2021 22:29:09 -0500 (EST) In-Reply-To: <87lfatul18.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 12 Mar 2021 04:07:47 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:202135 Archived-At: Lars Ingebrigtsen [2021-03-12 04:07:47] wrote: > Stefan Monnier 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))