Re: [PATCH v4 1/2] compiler.h: add const_true()

From: Vincent Mailhol
Date: Sun Nov 17 2024 - 22:22:56 EST


On Mon. 18 nov. 2024 à 07:58, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> The "0*!(x)" is admittedly kind of ugly, and might be prettier as
> "0&&(x)". Same number of characters, but technically one op less and
> not mixing booleans and integer ops.

I did a tree wide replacement of __is_constexpr() with is_const() and
did an allyesconfig build test. It yields a -Wint-in-bool-context
warning in GCC for both the "0*!(x)" and the "0&&(x)" each time the
expression contains non-boolean operators, for example: * or <<.

I reproduced it in godbolt here:

https://godbolt.org/z/5Wcbvanq3

Aside from this warning, the allyesconfig build succeeded.


Yours sincerely,
Vincent Mailhol