bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* lib/malloca.c, different signs of integers; with clang and groff
@ 2024-02-03 13:35 Bjarni Ingi Gislason
  2024-02-04  6:33 ` Paul Eggert
  2024-02-05 19:05 ` Bjarni Ingi Gislason
  0 siblings, 2 replies; 6+ messages in thread
From: Bjarni Ingi Gislason @ 2024-02-03 13:35 UTC (permalink / raw)
  To: bug-gnulib

  CC       lib/libgnu_a-malloca.o
../lib/malloca.c:61:38: warning: comparison of integers of
different signs: 'size_t' (aka 'unsigned long') and 'idx_t' (aka
'long') [-Wsign-compare]
  if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1))
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/xalloc-oversized.h:62:33: note: expanded from macro
'xalloc_oversized'
# define xalloc_oversized(n, s) __xalloc_oversized (n, s)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~
../lib/xalloc-oversized.h:33:8: note: expanded from macro
'__xalloc_oversized'
       < (n)))
       ^  ~
1 warning generated.



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

* Re: lib/malloca.c, different signs of integers; with clang and groff
  2024-02-03 13:35 lib/malloca.c, different signs of integers; with clang and groff Bjarni Ingi Gislason
@ 2024-02-04  6:33 ` Paul Eggert
  2024-02-05  9:25   ` Bruno Haible
  2024-02-05 19:05 ` Bjarni Ingi Gislason
  1 sibling, 1 reply; 6+ messages in thread
From: Paul Eggert @ 2024-02-04  6:33 UTC (permalink / raw)
  To: Bjarni Ingi Gislason, bug-gnulib

On 2024-02-03 05:35, Bjarni Ingi Gislason wrote:
>    CC       lib/libgnu_a-malloca.o
> ../lib/malloca.c:61:38: warning: comparison of integers of
> different signs: 'size_t' (aka 'unsigned long') and 'idx_t' (aka
> 'long') [-Wsign-compare]

This is a false alarm, as both sides of the comparison are nonnegative.

I recommend avoiding -Wsign-compare when compiling Gnulib .c files, as 
the false positive rate is too large.



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

* Re: lib/malloca.c, different signs of integers; with clang and groff
  2024-02-04  6:33 ` Paul Eggert
@ 2024-02-05  9:25   ` Bruno Haible
  0 siblings, 0 replies; 6+ messages in thread
From: Bruno Haible @ 2024-02-05  9:25 UTC (permalink / raw)
  To: Bjarni Ingi Gislason, bug-gnulib; +Cc: Paul Eggert

Paul Eggert wrote:
> I recommend avoiding -Wsign-compare when compiling Gnulib .c files, as 
> the false positive rate is too large.

+1.

We already document this in the Gnulib manual:
https://www.gnu.org/software/gnulib/manual/html_node/manywarnings.html

More generally, we turn off such warnings for most of the Gnulib code, through
the variable GL_CFLAG_GNULIB_WARNINGS, set through m4/gnulib-common.m4.
Therefore, we *don't want to hear* about warnings of these categories:

    -Wcast-qual
    -Wconversion
    -Wfloat-conversion
    -Wfloat-equal
    -Wpedantic
    -Wsign-compare
    -Wsign-conversion
    -Wtautological-out-of-range-compare
    -Wtype-limits
    -Wundef
    -Wunsuffixed-float-constants
    -Wunused-function
    -Wunused-parameter

Bruno





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

* Re: lib/malloca.c, different signs of integers; with clang and groff
  2024-02-03 13:35 lib/malloca.c, different signs of integers; with clang and groff Bjarni Ingi Gislason
  2024-02-04  6:33 ` Paul Eggert
@ 2024-02-05 19:05 ` Bjarni Ingi Gislason
  2024-02-05 19:58   ` Bruno Haible
  1 sibling, 1 reply; 6+ messages in thread
From: Bjarni Ingi Gislason @ 2024-02-05 19:05 UTC (permalink / raw)
  To: bug-gnulib

  The cause is an error in "Makefile.in" (lines folded):

lib/libgnu_a-malloca.o: lib/malloca.c
        $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(AM_CPPFLAGS) $(CPPFLAGS) $(lib_libgnu_a_CFLAGS) $(CFLAGS) -MT
lib/libgnu_a-malloca.o -MD -MP -MF
lib/$(DEPDIR)/libgnu_a-malloca.Tpo -c -o lib/libgnu_a-malloca.o
`test -f 'lib/malloca.c' || echo '$(srcdir)/'`lib/malloca.c

$(lib_libgnu_a_CFLAGS) is put before $(CFLAGS).

  I have not found the place where such lines are constructed.


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

* Re: lib/malloca.c, different signs of integers; with clang and groff
  2024-02-05 19:05 ` Bjarni Ingi Gislason
@ 2024-02-05 19:58   ` Bruno Haible
  2024-02-05 20:18     ` Jeffrey Walton
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2024-02-05 19:58 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Bjarni Ingi Gislason

Bjarni Ingi Gislason wrote:
> $(lib_libgnu_a_CFLAGS) is put before $(CFLAGS).

This is as it should be. The user-provided CFLAGS must override the
package-provided lib_libgnu_a_CFLAGS. Rationale: "The user is always right".

>   I have not found the place where such lines are constructed.

Makefile.in is constructed by Automake.

Bruno





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

* Re: lib/malloca.c, different signs of integers; with clang and groff
  2024-02-05 19:58   ` Bruno Haible
@ 2024-02-05 20:18     ` Jeffrey Walton
  0 siblings, 0 replies; 6+ messages in thread
From: Jeffrey Walton @ 2024-02-05 20:18 UTC (permalink / raw)
  To: Bjarni Ingi Gislason; +Cc: bug-gnulib

On Mon, Feb 5, 2024 at 2:59 PM Bruno Haible <bruno@clisp.org> wrote:
>
> Bjarni Ingi Gislason wrote:
> > $(lib_libgnu_a_CFLAGS) is put before $(CFLAGS).
>
> This is as it should be. The user-provided CFLAGS must override the
> package-provided lib_libgnu_a_CFLAGS. Rationale: "The user is always right".

++. See <https://www.gnu.org/prep/standards/html_node/Command-Variables.html>:

    Put CFLAGS last in the compilation command, after other variables
    containing compiler options, so the user can use CFLAGS to override
    the others.

> >   I have not found the place where such lines are constructed.
>
> Makefile.in is constructed by Automake.

Jeff


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

end of thread, other threads:[~2024-02-05 20:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-03 13:35 lib/malloca.c, different signs of integers; with clang and groff Bjarni Ingi Gislason
2024-02-04  6:33 ` Paul Eggert
2024-02-05  9:25   ` Bruno Haible
2024-02-05 19:05 ` Bjarni Ingi Gislason
2024-02-05 19:58   ` Bruno Haible
2024-02-05 20:18     ` Jeffrey Walton

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