unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* GCC 7 warnings
@ 2017-09-09 16:16 Eli Zaretskii
  2017-09-09 18:27 ` Paul Eggert
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2017-09-09 16:16 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Richard Copley, emacs-devel

In http://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00151.html,
Richard Copley sent a build log using GCC 7, which reveals several
warnings I think are unrelated to MS-Windows.

First, there are several warnings about fallthrough.  Example:

    CC       tparam.o
  tparam.c: In function 'tparam1':
  tparam.c:126:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
	  if (tem < 100)
	     ^
  tparam.c:128:6: note: here
	case '3':  /* %3 means output in decimal, 3 digits.  */
	^~~~

It turns out we use the -Wimplicit-fallthrough=5 GCC option, which
rejects any previously supported fall-through comments, and instead
insists on using __attribute__((fallthrough)), which triggers warnings
in older versions of GCC.

Paul, why do we use level 5 here, instead of using level 3, the
default?  Level 3 supports the /* FALLTHROUGH */ and similar comments
that indicate a fall-through in a more portable way.  We already have
such comments in many places.

I also see warnings in image.c:

    CC       image.o
  In file included from image.c:33:0:
  image.c: In function 'xbm_scan':
  ../lib/c-ctype.h:185:3: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
     switch (c)
     ^~~~~~
  image.c:2577:17: note: 'c' was declared here
     unsigned char c;
		   ^
  image.c: In function 'gif_load':
  image.c:7902:24: warning: 'bgcolor' may be used uninitialized in this function [-Wmaybe-uninitialized]
	  pixel_colors[i] = STRINGP (specified_bg)

(There were a few more warnings which I fixed.)

Thanks.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC 7 warnings
  2017-09-09 16:16 GCC 7 warnings Eli Zaretskii
@ 2017-09-09 18:27 ` Paul Eggert
  2017-09-09 19:29   ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Eggert @ 2017-09-09 18:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Richard Copley, emacs-devel

Eli Zaretskii wrote:
> Paul, why do we use level 5 here, instead of using level 3, the
> default?  Level 3 supports the /* FALLTHROUGH */ and similar comments
> that indicate a fall-through in a more portable way.

Those comments have problems of their own, as they don't play well with macros 
and with non-GCC auditing tools that look at preprocessor output. So in other 
GNU projects we use level 5. It's easy enough to use it portably, and we've done 
that elsewhere in Emacs with the FALLTHROUGH macro. I just never noticed 
tparam.c since I never compiled it. I fixed it just now.

Many of the problems you ran into are because of my 2016-05-30 patch "Omit 
IF_LINT code that no longer seems needed" that simplified the code by assuming a 
recent-enough GCC for --enable-gcc-warnings.

There is a tradeoff for --enable-gcc-warnings. If we try to support ancient GCC 
compilers, we'll have to complicate the code and consume scarce maintenance 
resources. If we support only the latest GCC, developers using slightly-older 
GCCs will get some annoying warnings when they use --enable-gcc-warnings. I 
prefer to push the bleeding edge here, and ask developers who use 
--enable-gcc-warnings to at most (say) a year-old GCC version, as this saves 
some work for the rest of us. Of course we can't expect everybody to immediately 
sync to the latest GCC when released, but on the other hand there is a cost to 
supporting too-old GCCs, a cost I'd rather not pay (since I bear a good deal of 
it...).

By the way, I find the UNINIT macro to be more readable than supplying nonce 
expressions, as UNINIT clearly indicates to the reader that the variable is 
intended to be uninitialized. So I used that as part of my fixups. The 
pre-2016-05-30 version of the code was using UNINIT anyway.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC 7 warnings
  2017-09-09 18:27 ` Paul Eggert
@ 2017-09-09 19:29   ` Eli Zaretskii
  2017-09-09 20:30     ` Paul Eggert
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2017-09-09 19:29 UTC (permalink / raw)
  To: Paul Eggert; +Cc: rcopley, emacs-devel

> Cc: emacs-devel@gnu.org, Richard Copley <rcopley@gmail.com>
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Sat, 9 Sep 2017 11:27:40 -0700
> 
> There is a tradeoff for --enable-gcc-warnings. If we try to support ancient GCC 
> compilers, we'll have to complicate the code and consume scarce maintenance 
> resources. If we support only the latest GCC, developers using slightly-older 
> GCCs will get some annoying warnings when they use --enable-gcc-warnings. I 
> prefer to push the bleeding edge here, and ask developers who use 
> --enable-gcc-warnings to at most (say) a year-old GCC version, as this saves 
> some work for the rest of us. Of course we can't expect everybody to immediately 
> sync to the latest GCC when released, but on the other hand there is a cost to 
> supporting too-old GCCs, a cost I'd rather not pay (since I bear a good deal of 
> it...).

We already filter the warnings by GCC version.  We just needto filter
more, perhaps, and not just based on what GCC supports.

Since --enable-gcc-warnings is on by default for building the
development version, it needs to build relatively cleanly with a
reasonably recent GCC.  It's okay to have the code ready for the
bleeding edge, but if that triggers warnings with slightly older GCC,
it's counter-productive IMO, because asking developers to use GCC
which is too new might waste their time due to GCC bugs.  GCC 6 or 5
is not yet old enough to cause those who use them such trouble.

> By the way, I find the UNINIT macro to be more readable than supplying nonce 
> expressions, as UNINIT clearly indicates to the reader that the variable is 
> intended to be uninitialized.

This is a matter of personal style preferences.  I find the syntax of
UNINIT confusing, because it's not C-like.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC 7 warnings
  2017-09-09 19:29   ` Eli Zaretskii
@ 2017-09-09 20:30     ` Paul Eggert
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Eggert @ 2017-09-09 20:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rcopley, emacs-devel

Eli Zaretskii wrote:
> Since --enable-gcc-warnings is on by default for building the
> development version, it needs to build relatively cleanly with a
> reasonably recent GCC.  It's okay to have the code ready for the
> bleeding edge, but if that triggers warnings with slightly older GCC,
> it's counter-productive IMO, because asking developers to use GCC
> which is too new might waste their time due to GCC bugs.  GCC 6 or 5
> is not yet old enough to cause those who use them such trouble.

GCC 5.4 is OK. I still test with it, at times. Not sure it's worth going back 
further than that though, for developers.

I don't use bleeding-edge GCC, which is GCC 8 (not released yet).  I haven't 
even upgraded yet to the latest stable release, 7.2.0. So I'm not really 
bleeding-edge.

In my experience GCC 7 is more reliable than older versions, for compiling C 
programs.  I don't recommend using GCC 8 for production, though.

The point of the May 2016 cleanup was to remove gorp like UNINIT (and it is 
admittedly awkward) when GCC had gotten smart enough that the gorp wasn't 
needed. Unfortunately there is no easy way to make UNINIT's syntax C-like, at 
least not with current GCC. In the meantime UNINIT's technical advantages 
outweigh its stylistic awkwardness.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-09 20:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-09 16:16 GCC 7 warnings Eli Zaretskii
2017-09-09 18:27 ` Paul Eggert
2017-09-09 19:29   ` Eli Zaretskii
2017-09-09 20:30     ` Paul Eggert

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).