[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lib/malloca.c: warning about [-Wsign-compare]
From: |
Bjarni Ingi Gislason |
Subject: |
Re: lib/malloca.c: warning about [-Wsign-compare] |
Date: |
Thu, 22 Sep 2022 18:20:56 +0000 |
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 <stdckdint.h>
> ^~~~~~~~~~~~~
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' ..."