[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] maint: avoid uniq.c warning from bleeding-edge gcc's -Wstric
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] maint: avoid uniq.c warning from bleeding-edge gcc's -Wstrict-overflow |
Date: |
Thu, 15 Oct 2015 17:23:18 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 15/10/15 17:14, Jim Meyering wrote:
> I build gcc from git regularly, and my first test is to use it to
> build coreutils.
> Today's gcc exposed this nit:
>
>
> 0001-maint-avoid-uniq.c-warning-from-bleeding-edge-gcc-s-.patch
>
>
> From 74f62ef8b31993a7290cafb22c2384543afdad80 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <address@hidden>
> Date: Thu, 15 Oct 2015 09:09:18 -0700
> Subject: [PATCH] maint: avoid uniq.c warning from bleeding-edge gcc's
> -Wstrict-overflow
>
> * src/uniq.c (main): Change type of "nfiles" to unsigned int,
> to avoid a brand new warning from a gcc I built from today's
> sources (gcc version 6.0.0 20151015 (experimental) (GCC)):
> src/uniq.c:523:14: error: assuming signed overflow does not occur \
> when simplifying conditional to constant [-Werror=strict-overflow]
> if (nfiles == 2)
> ^
> ---
> src/uniq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/uniq.c b/src/uniq.c
> index 8dfb7ea..7b77dd3 100644
> --- a/src/uniq.c
> +++ b/src/uniq.c
> @@ -483,7 +483,7 @@ main (int argc, char **argv)
> int optc = 0;
> bool posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
> enum Skip_field_option_type skip_field_option_type = SFO_NONE;
> - int nfiles = 0;
> + unsigned int nfiles = 0;
How about size_t since it's used as an array index?
cheers,
Pádraig