unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: emacs-devel@gnu.org
Cc: Richard Copley <rcopley@gmail.com>, Eli Zaretskii <eliz@gnu.org>
Subject: Re: C warning in MSYS2 build
Date: Thu, 5 Oct 2017 12:32:26 -0700	[thread overview]
Message-ID: <281d43c7-b3a9-be40-a8e7-c8021c286f59@cs.ucla.edu> (raw)
In-Reply-To: <83inftwhlb.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]

On 10/05/2017 11:54 AM, Eli Zaretskii wrote:
> Thanks, but it isn't new.

In my experience this kind of warning can appear and vanish almost at 
whim: compiling at a different optimization levels, or changing 
compilation in some other way, can cause GCC to omit or include the 
warning. So possibly Richard wasn't getting the warning a day ago, but 
got the warning after changing from -O2 to -O0 (or whatever), or by 
upgrading GCC.

If it's a major annoyance we could disable --Wnull-dereference for 
indent.c. I hope that's not needed, though.

Come to think of it, last year I filed a GCC bug report about a similar 
problem with lib-src/etags.c and -Wnull-dereference, here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71157

The GCC bug is not fixed yet. etags.c confused GCC by using an 
assignment inside an 'if' expression, which is contrary to the usual GNU 
style, and last year I worked around the GCC bug by changing etags.c to 
use a cleaner style. I notice that indent.c also has an assignment 
inside an 'if' expression that is relevant to these warnings. Richard, 
does it help to recode indent.c to use the usual GNU style, as in the 
attached patch? If so, let's do that instead. (Perhaps we should do that 
anyway....)


[-- Attachment #2: indent.diff --]
[-- Type: text/x-patch, Size: 761 bytes --]

diff --git a/src/indent.c b/src/indent.c
index 26507b5eb5..79841a3d2c 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -76,15 +76,17 @@ buffer_display_table (void)
 static int
 character_width (int c, struct Lisp_Char_Table *dp)
 {
-  Lisp_Object elt;
-
   /* These width computations were determined by examining the cases
      in display_text_line.  */
 
   /* Everything can be handled by the display table, if it's
      present and the element is right.  */
-  if (dp && (elt = DISP_CHAR_VECTOR (dp, c), VECTORP (elt)))
-    return ASIZE (elt);
+  if (dp)
+    {
+      Lisp_Object elt = DISP_CHAR_VECTOR (dp, c);
+      if (VECTORP (elt))
+	return ASIZE (elt);
+    }
 
   /* Some characters are special.  */
   if (c == '\n' || c == '\t' || c == '\015')

  reply	other threads:[~2017-10-05 19:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-05 17:44 C warning in MSYS2 build Richard Copley
2017-10-05 18:54 ` Eli Zaretskii
2017-10-05 19:32   ` Paul Eggert [this message]
2017-10-05 20:08     ` Richard Copley
2017-10-05 22:44       ` Paul Eggert
2017-10-06 15:16     ` Richard Stallman
2017-10-06 17:23       ` Richard Copley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=281d43c7-b3a9-be40-a8e7-c8021c286f59@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rcopley@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).