Subject: bug#23442: closed (Re: bug#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental))

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 05 May 2016 15:18:02 +0000

Your bug report

#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental)

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
23442: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23442
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental)
From: Jim Meyering <[email-masked]>
To: Bernhard Voelker <[email-masked]>
Cc: [email-masked]
Date: Thu, 5 May 2016 08:17:18 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

On Thu, May 5, 2016 at 1:54 AM, Bernhard Voelker
<[email-masked]> wrote:
> On 05/04/2016 05:08 PM, Jim Meyering wrote:
>> Subject: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503
>>  (experimental)
>>
>> * src/id.c (main): When configured with --enable-gcc-warnings and using
>> the very latest gcc built from git, building would fail with this:
>>   src/id.c:200:8: error: assuming signed overflow does not occur when \
>>     simplifying conditional to constant [-Werror=strict-overflow]
>>      bool default_format = (just_user + just_group + just_group_list
>>           ^~~~~~~~~~~~~~
>> Rewrite to use bool-appropriate operators.
>
> Thanks, that looks much cleaner.

Thanks again. Pushed and closed.

Subject: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental)
From: Jim Meyering <[email-masked]>
To: [email-masked]
Date: Tue, 3 May 2016 20:59:32 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

coreutils failed to build when configured with --enable-gcc-warnings
and the latest gcc built from git.

Here's a patch to fix that:
From e22ff987e4d3c29b445b3e94de65c633f8a05870 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Tue, 3 May 2016 20:56:20 -0700
Subject: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503
 (experimental)

* src/id.c (main): When configured with --enable-gcc-warnings and using
the very latest gcc built from git, building would fail with this:
  src/id.c:200:8: error: assuming signed overflow does not occur when \
    simplifying conditional to constant [-Werror=strict-overflow]
     bool default_format = (just_user + just_group + just_group_list
          ^~~~~~~~~~~~~~
Add "U0" to those boolean addends, to avoid the warning by widening
the type of the sum.
---
 src/id.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/id.c b/src/id.c
index 38844af..3969337 100644
--- a/src/id.c
+++ b/src/id.c
@@ -197,7 +197,7 @@ main (int argc, char **argv)
   if (just_user + just_group + just_group_list + just_context > 1)
     error (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice"));

-  bool default_format = (just_user + just_group + just_group_list
+  bool default_format = (0U + just_user + just_group + just_group_list
                          + just_context == 0);

   if (default_format && (use_real || use_name))
-- 
2.8.0-rc2