Re: lib/malloca.c: warning about [-Wsign-compare]

2022-09-23 Thread Simon Josefsson via Gnulib discussion list
Paul Eggert  writes:

> On 9/22/22 11:20, Bjarni Ingi Gislason wrote:
>
>> CC='clang -Wsign-compare' ./gnulib-tool --test malloca 2>
>
> Oh, please don't use -Wsign-compare. Clang generates too many false
> alarms with -Wsign-compare, we don't recommend that warning, and 
> Gnulib-using programs generally don't enable that warning when
> compiling Gnulib code.
>
> If you happen to find a real bug with that warning we'd like to know
> it. But please don't bother us with the false alarms; they're not
> worth your time or ours.

I added a similar comment to the manual: it is handy with a reference
for people like me who cannot remember all different warning flags and
whether they are generally useful or not.

/Simon
From 54c09c98a67219ba2cf70c4bb23f80990db37066 Mon Sep 17 00:00:00 2001
From: Simon Josefsson 
Date: Fri, 23 Sep 2022 09:06:22 +0200
Subject: [PATCH] warnings, manywarnings: Doc fixes.

* doc/manywarnings.texi (manywarnings): Improve usage instruction.
Start list of comments on particular warning flags, based on
comment from Paul Eggert .
* doc/warnings.texi (warnings): Mention that it is often used with manywarnings.
---
 ChangeLog |  8 
 doc/manywarnings.texi | 14 +-
 doc/warnings.texi |  4 +++-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a6399f1048..5b5804df68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-09-23  Simon Josefsson  
+
+	warnings, manywarnings: Doc fixes.
+	* doc/manywarnings.texi (manywarnings): Improve usage instruction.
+	Start list of comments on particular warning flags, based on
+	comment from Paul Eggert .
+	* doc/warnings.texi (warnings): Mention that it is often used with manywarnings.
+
 2022-09-21  Paul Eggert  
 
 	assert-h: suppress clang false alarms
diff --git a/doc/manywarnings.texi b/doc/manywarnings.texi
index 1b3e5907be..7ab3f09cee 100644
--- a/doc/manywarnings.texi
+++ b/doc/manywarnings.texi
@@ -32,7 +32,7 @@ go through the list of warnings. You will likely deactivate warnings that
 occur often and don't point to mistakes in the code, by adding them to the
 @samp{nw} variable, then reconfiguring and recompiling. When warnings point
 to real mistakes and bugs in the code, you will of course not disable
-them.
+them but fix your code to silence the warning instead.
 
 There are also many GCC warning options which usually don't point to mistakes
 in the code; these warnings enforce a certain programming style. It is a
@@ -44,3 +44,15 @@ When a new version of GCC is released, you can add the new warning options
 that it introduces into the @code{gl_MANYWARN_ALL_GCC} macro (and submit your
 modification to the Gnulib maintainers :-)), and enjoy the benefits of the
 new warnings, while adding the undesired ones to the @samp{nw} variable.
+
+Comments on particular warning flags:
+
+@table @samp
+
+@item -Wsign-compare
+Clang generates too many false alarms with -Wsign-compare, and we don't
+recommend that warning.  Programs using Gnulib generally don't enable
+that warning when compiling Gnulib code.  If you happen to find a real
+bug with that warning we'd like to know it.
+
+@end table
diff --git a/doc/warnings.texi b/doc/warnings.texi
index 1836c04325..47ce633250 100644
--- a/doc/warnings.texi
+++ b/doc/warnings.texi
@@ -2,7 +2,9 @@
 @section warnings
 
 The @code{warnings} module allows to regularly build a package with more
-GCC warnings than the default warnings emitted by GCC.
+GCC warnings than the default warnings emitted by GCC.  It is often used
+indirectly through the @code{manywarnings} module
+(@pxref{manywarnings}).
 
 It provides the following functionality:
 
-- 
2.30.2



signature.asc
Description: PGP signature


Re: lib/malloca.c: warning about [-Wsign-compare]

2022-09-22 Thread Bjarni Ingi Gislason
On Wed, Sep 21, 2022 at 05:15:50PM -0700, Paul Eggert wrote:
> On 9/21/22 14:42, Bjarni Ingi Gislason wrote:
> 
> > you do not say for what you want (need) all this data.
> 
> We need a reproducer to figure out what is causing the problem. Perhaps the
> problem involves something going wrong and generating the wrong config.h or
> Makefile. If so, what is it?
> 
> 
> >If your are seeking a reproducer this works for me:
> > 
> >Compilation in your gnulib directory:
> > 
> > clang -I . -Wsign-compare -c lib/malloca.c
> > 
> > with ./config.h coming from the attachment (compressed file).
> 
> Sorry, that's not a reproducer. First, if the problem is that the config.h
> is wrong, this won't tell us why config.h went wrong. Second, if the problem
> is in the Makefile this won't show it to us. Third, even if I simply put
> that config.h in my gnulib directory and run that command, it won't compile
> for me (Fedora 36 x86-64, which has clang 14.0.5 (Fedora 14.0.5-1.fc36)):
> 
> $ clang -I . -Wsign-compare -c lib/malloca.c
> lib/malloca.c:24:10: fatal error: 'stdckdint.h' file not found
> #include 
>  ^

  I had copied this file from that generated in groff to /usr/include
and changed " around its name to < and >.

> 
> We need a complete reproducer from scratch, not just dribs and drabs. If
> it's too much work for you to generate one that's OK, we can wait until
> someone else runs into the issue, whatever it is.
> 
  I think so given that this is a compilation warning.

> Here's the shell command that I used to try to reproduce the problem on
> Fedora 36 x86-64, from a fresh Gnulib checkout. This shell command succeeded
> for me. Can you alter this recipe so that I can easily reproduce the problem
> with an altered recipe, so that the test fails?
> 
>   CC=clang ./gnulib-tool --test malloca
> 

  Yes (hopefully).


  When I use

CC='clang -Wsign-compare' ./gnulib-tool --test malloca 2>
test.malloca.err > testmalloca.std

I get no failure but a lot on standard error.

cat test.malloca.err | sed  -e 's/\:[0-9]*\:[0-9]*\:/\:/' | grep -F
'warning:' | sort -u 

gives

../../gllib/malloca.c: warning: comparison of integers of different signs: 
'unsigned long' and 'idx_t' (aka 'long') [-Wsign-compare]
../../gllib/malloca.c: warning: '_Static_assert' with no message is a C2x 
extension [-Wc2x-extensions]
../../gltests/test-assert.c: warning: '_Static_assert' with no message is a C2x 
extension [-Wc2x-extensions]
../../gltests/test-intprops.c: warning: comparison of integers of different 
signs: 'int' and 'unsigned int' [-Wsign-compare]
../../gltests/test-intprops.c: warning: comparison of integers of different 
signs: 'int' and 'unsigned long' [-Wsign-compare]
../../gltests/test-intprops.c: warning: comparison of integers of different 
signs: 'unsigned long long' and 'int' [-Wsign-compare]
../../gltests/test-intprops.c: warning: '_Static_assert' with no message is a 
C2x extension [-Wc2x-extensions]
../../gltests/test-limits-h.c: warning: '_Static_assert' with no message is a 
C2x extension [-Wc2x-extensions]
../../gltests/test-stdalign.c: warning: '_Static_assert' with no message is a 
C2x extension [-Wc2x-extensions]
../../gltests/test-stddef.c: warning: '_Static_assert' with no message is a C2x 
extension [-Wc2x-extensions]
../../gltests/test-stdlib.c: warning: '_Static_assert' with no message is a C2x 
extension [-Wc2x-extensions]
../../gltests/test-string.c: warning: '_Static_assert' with no message is a C2x 
extension [-Wc2x-extensions]
../../gltests/test-unistd.c: warning: '_Static_assert' with no message is a C2x 
extension [-Wc2x-extensions]
../../gltests/test-wchar.c: warning: '_Static_assert' with no message is a C2x 
extension [-Wc2x-extensions]


  To get a failure I had to "cheat", added a pragma to "tests/test-malloca.c"

#pragma GCC diagnostic ignored "-Wno-error"


and run with "CC='clang -Werror=sign-compare' ..."




Re: lib/malloca.c: warning about [-Wsign-compare]

2022-09-22 Thread Paul Eggert

On 9/22/22 11:20, Bjarni Ingi Gislason wrote:


CC='clang -Wsign-compare' ./gnulib-tool --test malloca 2>


Oh, please don't use -Wsign-compare. Clang generates too many false 
alarms with -Wsign-compare, we don't recommend that warning, and 
Gnulib-using programs generally don't enable that warning when compiling 
Gnulib code.


If you happen to find a real bug with that warning we'd like to know it. 
But please don't bother us with the false alarms; they're not worth your 
time or ours.




Re: lib/malloca.c: warning about [-Wsign-compare]

2022-09-21 Thread Paul Eggert

On 9/21/22 14:42, Bjarni Ingi Gislason wrote:


you do not say for what you want (need) all this data.


We need a reproducer to figure out what is causing the problem. Perhaps 
the problem involves something going wrong and generating the wrong 
config.h or Makefile. If so, what is it?




   If your are seeking a reproducer this works for me:

   Compilation in your gnulib directory:

clang -I . -Wsign-compare -c lib/malloca.c

with ./config.h coming from the attachment (compressed file).


Sorry, that's not a reproducer. First, if the problem is that the 
config.h is wrong, this won't tell us why config.h went wrong. Second, 
if the problem is in the Makefile this won't show it to us. Third, even 
if I simply put that config.h in my gnulib directory and run that 
command, it won't compile for me (Fedora 36 x86-64, which has clang 
14.0.5 (Fedora 14.0.5-1.fc36)):


$ clang -I . -Wsign-compare -c lib/malloca.c
lib/malloca.c:24:10: fatal error: 'stdckdint.h' file not found
#include 
 ^

We need a complete reproducer from scratch, not just dribs and drabs. If 
it's too much work for you to generate one that's OK, we can wait until 
someone else runs into the issue, whatever it is.


Here's the shell command that I used to try to reproduce the problem on 
Fedora 36 x86-64, from a fresh Gnulib checkout. This shell command 
succeeded for me. Can you alter this recipe so that I can easily 
reproduce the problem with an altered recipe, so that the test fails?


  CC=clang ./gnulib-tool --test malloca




Re: lib/malloca.c: warning about [-Wsign-compare]

2022-09-21 Thread Bruno Haible
Bjarni Ingi Gislason wrote:
> > Please use the bug report template from
> > .
> > 
>   Hi,
> 
> you do not say for what you want (need) all this data.

I need all this data because

  1) What appears to be a simple warning, to fix in malloca.c, is not like
 this. We have code in place (in gnulib-tool and the *.m4 macros) whose
 effect should be to neutralize -Wsign-compare options that you may have
 in $CC, when compiling malloca.c. We will therefore NOT change malloca.c
 to remove such a warning. Instead what needs to be done is to look why
 the GL_CFLAG_GNULIB_WARNINGS mechanics does not work in your environment.
 For this we need a "How to reproduce" of the whole package.

 In summary: Don't assume that a question/report that looks simple to you
 is simple to fix.

  2) Several times already, you reported problems to us that were not repro-
 ducible by me or Paul. I formulated the bug report template in such a
 way that (hopefully) you will reproduce the problem in an directory that
 was created and populated from scratch, before you report it to us.

> clang -I . -Wsign-compare -c lib/malloca.c

Invalid bug report. See above.

Bruno






Re: lib/malloca.c: warning about [-Wsign-compare]

2022-09-21 Thread Bjarni Ingi Gislason
On Mon, Sep 19, 2022 at 02:39:35AM +0200, Bruno Haible wrote:
> Bjarni,
> 
> Please use the bug report template from
> .
> 
  Hi,

you do not say for what you want (need) all this data.

  If your are seeking a reproducer this works for me:

  Compilation in your gnulib directory:

clang -I . -Wsign-compare -c lib/malloca.c

with ./config.h coming from the attachment (compressed file).



config.h.gz
Description: application/gzip


Re: lib/malloca.c: warning about [-Wsign-compare]

2022-09-18 Thread Bruno Haible
Bjarni,

Please use the bug report template from
.

Bruno