bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Jim Meyering
Subject: bug#23442: [PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental)
Date: Wed, 4 May 2016 08:08:21 -0700

On Wed, May 4, 2016 at 12:40 AM, Bernhard Voelker
<address@hidden> 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:

Attachment: 0001-maint-avoid-new-warning-from-gcc-GCC-7.0.0-20160503-.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]