GNU bug report logs -
#23442
[PATCH] maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental)
Previous Next
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.
Full log
View this message in rfc822 format
[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)]
This bug report was last modified 9 years and 22 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.