Re: [PATCH 0/4] Fix the x86 defconfig build with GCC 17
From: Borislav Petkov
Date: Wed Nov 04 2026 - 21:36:08 EST
On November 4, 2026 6:05:27 PM UTC, Vineet Gupta <vineet.gupta@xxxxxxxxx> wrote:
>+CC Jakub
>
>On 11/4/26 8:27 AM, Borislav Petkov wrote:
>> On Wed, Nov 04, 2026 at 08:07:17AM -0800, Vineet Gupta wrote:
>>> Fix build warnings and failures (CONFIG_WERROR=y) with a GCC 17 build.
>>> GCC 17 adds -Wconstant-logical-operand which is strict about operands
>>> of && or || that fold to a constant other than 0 or 1.
>> Just from looking at it, my initial reaction would be to disable that option.
>>
>> Because, frankly, I don't see the point.
>
>Here's my 2 cents:
>
>I wondered if this brings any codegen improvements, since we are telling the compiler that something is 0 or 1 vs. some other range before. And it doesn't, because of the way it is used. So focusing on just 1/4.
>
>- Constant bit: __builtin_constant_p(bit) && MASK_BIT_SET(bit) folds at compile time to the same truth value, with or without the !! bool conversion.
>- Variable bit: __builtin_constant_p(bit) is 0, so && short-circuits and the mask is never evaluated.
>
>Basically, the masked value never reaches generated code, so compiler gets nothing new to work with.
>
>So I did some digging, and turns out that it can be helpful to catch bugs in the source code itself. In fact GCC implemented the toggle at all, when Jakub spotted an issue with a typo: (data->flags && ff_genericize) vs. (data->flags & ff_genericize).
>
>In kernel, the predicate like *_BIT_SET() not returning a bool is not clean IMO and it used to return 0/1 before anyway so its not like we are going out of the way here.
>
>I'm mildly in the favor of keeping the warning, but ultimately your call, I can respin with it disabled.
>
>Thx,
>-Vineet
You might wanna look at the W= switches we have for less popular and more noisy options
--
Small device. Typos and formatting crap