GNU bug report logs - #23442
[PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental)

Previous Next

Package: coreutils;

Reported by: Jim Meyering <jim <at> meyering.net>

Date: Wed, 4 May 2016 04:01:01 UTC

Severity: normal

Tags: patch

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23442 in the body.
You can then email your comments to 23442 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#23442; Package coreutils. (Wed, 04 May 2016 04:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jim Meyering <jim <at> meyering.net>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 04 May 2016 04:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: bug-coreutils <at> gnu.org
Subject: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503
 (experimental)
Date: Tue, 3 May 2016 20:59:32 -0700
[Message part 1 (text/plain, inline)]
coreutils failed to build when configured with --enable-gcc-warnings
and the latest gcc built from git.

Here's a patch to fix that:
[0001-maint-avoid-new-warning-from-gcc-GCC-7.0.0-20160503-.patch (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#23442; Package coreutils. (Wed, 04 May 2016 04:25:02 GMT) Full text and rfc822 format available.

Message #8 received at 23442 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: 23442 <at> debbugs.gnu.org
Subject: Re: bug#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0
 20160503 (experimental)
Date: Tue, 3 May 2016 21:23:59 -0700
On Tue, May 3, 2016 at 8:59 PM, Jim Meyering <jim <at> meyering.net> wrote:
> coreutils failed to build when configured with --enable-gcc-warnings
> and the latest gcc built from git.
>
> Here's a patch to fix that:

One nit in the commit log, fixed locally: s/U0/0U/




Information forwarded to bug-coreutils <at> gnu.org:
bug#23442; Package coreutils. (Wed, 04 May 2016 07:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 23442 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Jim Meyering <jim <at> meyering.net>, 23442 <at> debbugs.gnu.org
Subject: Re: bug#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0
 20160503 (experimental)
Date: Wed, 4 May 2016 09:40:05 +0200
On 05/04/2016 05:59 AM, Jim Meyering wrote:
> -  bool default_format = (just_user + just_group + just_group_list
> +  bool default_format = (0U + just_user + just_group + just_group_list
>                           + just_context == 0);

These are all bool - wouldn't it be better to use boolean instead of
arithmetical operators?

Have a nice day,
Berny




Information forwarded to bug-coreutils <at> gnu.org:
bug#23442; Package coreutils. (Wed, 04 May 2016 15:09:01 GMT) Full text and rfc822 format available.

Message #14 received at 23442 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Bernhard Voelker <mail <at> bernhard-voelker.de>
Cc: 23442 <at> debbugs.gnu.org
Subject: Re: bug#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0
 20160503 (experimental)
Date: Wed, 4 May 2016 08:08:21 -0700
[Message part 1 (text/plain, inline)]
On Wed, May 4, 2016 at 12:40 AM, Bernhard Voelker
<mail <at> bernhard-voelker.de> wrote:
> On 05/04/2016 05:59 AM, Jim Meyering wrote:
>> -  bool default_format = (just_user + just_group + just_group_list
>> +  bool default_format = (0U + just_user + just_group + just_group_list
>>                           + just_context == 0);
>
> These are all bool - wouldn't it be better to use boolean instead of
> arithmetical operators?

Thanks for the review. Indeed. Using "0U" there is a bit too much: a
hack upon the hack of using addition.

While using addition can be seen as slightly more readable (assuming
you know the idiom), or even better because the generated code is
jump-free, I would argue that this code should be readable, and that
whether there is a short-circuiting jump is irrelevant to the
performance of id.

While it is tempting to use "|" (the code generated by gcc-5.3 -O3 is
smaller and still jump-free: https://godbolt.org/g/zqMTtg), that still
feels dubious, especially when you remember that with gnulib, we may
still be simulating "bool" on some crufty systems.
So it seems best to use the bool-appropriate operators.

Here's the adjusted patch:
[0001-maint-avoid-new-warning-from-gcc-GCC-7.0.0-20160503-.patch (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#23442; Package coreutils. (Thu, 05 May 2016 08:56:02 GMT) Full text and rfc822 format available.

Message #17 received at 23442 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Jim Meyering <jim <at> meyering.net>
Cc: 23442 <at> debbugs.gnu.org
Subject: Re: bug#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0
 20160503 (experimental)
Date: Thu, 5 May 2016 10:54:57 +0200
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.

Have a nice day,
Berny




Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Thu, 05 May 2016 15:18:02 GMT) Full text and rfc822 format available.

Notification sent to Jim Meyering <jim <at> meyering.net>:
bug acknowledged by developer. (Thu, 05 May 2016 15:18:02 GMT) Full text and rfc822 format available.

Message #22 received at 23442-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Bernhard Voelker <mail <at> bernhard-voelker.de>
Cc: 23442-done <at> debbugs.gnu.org
Subject: Re: bug#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0
 20160503 (experimental)
Date: Thu, 5 May 2016 08:17:18 -0700
On Thu, May 5, 2016 at 1:54 AM, Bernhard Voelker
<mail <at> bernhard-voelker.de> 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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 03 Jun 2016 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.