[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" compla
From: |
Bruno Haible |
Subject: |
Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints |
Date: |
Wed, 08 Dec 2021 16:48:16 +0100 |
> especially given it's in the gcc -Wextra set, not some random flag
Warnings in the '-Wall' category are typically worth eliminating: they
regularly point to real bugs.
Eliminating '-Wsign-compare' warnings, OTOH, is usually a waste of time, in
my experience: I have hardly ever found a bug while chasing them.
Robbie Harwood wrote:
> > As you point out with coreutils, gnulib taking a position like this on
> > flags has the knock-on effect that, for our grub, we'll need to do one
> > of the following:
> >
> > - Carry a gnulib patch to make the flag work (what we've been doing).
> > - Change flags in the outer work (i.e., change build options for grub)
> > - Maintain logic to keep flags gnulib-disliked flags out when building
> > the gnulib modules
Paul Eggert replied:
> Every other Gnulib-using project I know takes the third approach.
So, how about adding the third approach to gnulib-tool?
Rationale:
Gnulib does not want to dictate their preferred GCC flags to coreutils,
grub, etc.
And similarly, we don't want coreutils, grub, etc. to dictate the coding
style in which gnulib is written.
Implementation idea:
Since 2021-06-10, gnulib-tool already ensures that the Gnulib modules are
compiled with '-Wno-error'. This code could be extended to add
'-Wno-sign-compare' and other warning-disabling options.
Question:
Which warning options should we disable this way?
1) We have some comments in build-aux/gcc-warning.spec.
2) When I collect all warnings in the gllib/ directory of a full testdir,
I get (with gcc-9.3):
$ grep warning: gllib.log | sed -e 's/^.*\[\(-W.*\)\]$/\1/' | LC_ALL=C sort |
LC_ALL=C uniq -c
72 -Wattribute-warning
169 -Wcast-qual
457 -Wconversion
1 -Wempty-body
10 -Wfloat-conversion
24 -Wfloat-equal
7 -Wimplicit-fallthrough=
9 -Wmaybe-uninitialized
5 -Wmissing-field-initializers
1 -Wpedantic
7 -Wredundant-decls
8 -Wrestrict
156 -Wsign-compare
4324 -Wsign-conversion
2 -Wtype-limits
888 -Wundef
139 -Wunsuffixed-float-constants
2 -Wunused-function
129 -Wunused-parameter
And with gcc-11.2.0:
$ grep warning: gllib.log | sed -e 's/^.*\[\(-W.*\)\]$/\1/' | LC_ALL=C sort |
LC_ALL=C uniq -c
72 -Wattribute-warning
172 -Wcast-qual
509 -Wconversion
4 -Wcpp
1 -Wempty-body
9 -Wfloat-conversion
26 -Wfloat-equal
7 -Wimplicit-fallthrough=
9 -Wmaybe-uninitialized
5 -Wmissing-field-initializers
432 -Wpedantic
7 -Wredundant-decls
8 -Wrestrict
2 -Wreturn-local-addr
168 -Wsign-compare
4362 -Wsign-conversion
2 -Wtype-limits
878 -Wundef
155 -Wunsuffixed-float-constants
2 -Wunused-function
131 -Wunused-parameter
I therefore propose to disable these warnings:
-Wattribute-warning
-Wcast-qual
-Wconversion
-Wfloat-conversion
-Wfloat-equal
-Wimplicit-fallthrough
-Wmaybe-uninitialized
-Wpedantic
-Wrestrict
-Wsign-compare
-Wsign-conversion
-Wtype-limits
-Wundef
-Wunsuffixed-float-constants
-Wunused-function
-Wunused-parameter
Bruno
- Re: [PATCH v2 05/10] Make gnulib's regcomp not abort(), (continued)
[PATCH v2 06/10] Make CFLAGS less painful, Robbie Harwood, 2021/12/01
[PATCH v2 07/10] Fix __argp_fmtstream_point()'s return type and comparisons with it, Robbie Harwood, 2021/12/01
[PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints, Robbie Harwood, 2021/12/01
- Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints, Paul Eggert, 2021/12/01
- Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints, Robbie Harwood, 2021/12/07
- Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints, Paul Eggert, 2021/12/07
- Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints,
Bruno Haible <=
- Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints, Jim Meyering, 2021/12/08
- Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints, Paul Eggert, 2021/12/08
- Re: [PATCH v2 08/10] Fix up a bunch of "gcc -Werror=sign-compare" complaints, Robbie Harwood, 2021/12/09
[PATCH v2 09/10] Paper over a stringop-overflow warning about wide char handling, Robbie Harwood, 2021/12/01
[PATCH v2 10/10] Fixup for -Werror=ignored-qualifiers issues, Robbie Harwood, 2021/12/01
Re: [PATCH v2 00/10] Code hygiene fixes from grub, Bruno Haible, 2021/12/01