as you brought it up, I guess we may as well discuss this on the list,
I assume because some developers often don't remember that `+` takes
precedence before `<<`, GCC warns now that one should place brackets
in such cases even if they aren't necessary.
On 08.01.21 01:37, Angel Pons wrote:
> Since register fields usually have more than one bit, I prefer to
> always use explicit shifts for consistency. The one case where I
> prefer the BIT() macro is to reduce the amount of nested braces when
> testing for individual bits in a mask. GCC encourages adding
> unnecessary braces for expressions such as `1 << x + 3`, so it's easy
> to end up with five levels of brace nesting in a single expression.
I've also seen some worrisome brackets inflation in other cases. IMO,
with too many brackets, one has to trace a line back and forth too much
to match opening and closing brackets, so it actually becomes much
harder to read.
So, my question is, do we actually want -Wparentheses? Or is it just
enabled because it's the default (with -Wall that is).
Alternatively, we could encourage other ways to handle such seemingly
ambiguity. For instance, one can store an intermediate value in a
(const) variable. That would spread a single calculation over multiple
lines, but it might be much easier to read than a forest of brackets.