All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Vineet Gupta <vineet.gupta@linux.dev>
Cc: Nicolas Schier <nsc@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Jakub Jelinek <jakub@redhat.com>,
	Julian Braha <julianbraha@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH v2] kbuild: move gcc's -Wconstant-logical-operand to W=2
Date: Thu, 5 Nov 2026 12:45:41 -0700	[thread overview]
Message-ID: <20261105194541.GA2668266@ax162> (raw)
In-Reply-To: <20261105175748.3057520-1-vineet.gupta@linux.dev>

On Thu, Nov 05, 2026 at 09:57:45AM -0800, Vineet Gupta wrote:
> GCC 17 adds -Wconstant-logical-operand to -Wall. It warns when an operand
> of && or || folds to a constant other than 0 or 1. Unlike clang's version,
> it also checks constant left operands and operators that come from a
> macro expansion. With CONFIG_WERROR=y, an x86 defconfig build fails in
> prepare0:
> 
>   arch/x86/include/asm/cpufeature.h:72:36: error: use of logical '&&' with constant operand '4194304' [-Werror=constant-logical-operand]
> 
> The warning is meant to catch && written for &. Kernel history has no
> such catch. Of the 13 earlier kernel fixes for clang's version, only
> commit dd7fe5d9fd6a ("rtc: max31335: Fix comparison in
> max31335_volatile_reg()") fixed a bug that the warning found. Commit
> 394b52462020 ("drm/i915/gem: fix bitwise and logical AND mixup") fixed a
> & written for &&, which the warning cannot see. The other fixes rewrote
> correct code. In GCC's own tree, the warning found two sites since it
> was added, and both were false positives.
> 
> Disable the warning for GCC unless W=2 is given. Keep clang's version,
> which skips macros and constant left operands.
> 
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Link: https://lore.kernel.org/all/20261104160722.1637541-1-vineet.gupta@linux.dev/
> Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

This probably wants a 'Cc: stable' so that older kernels can build
warning free with GCC 17.

-- 
Cheers,
Nathan

  parent reply	other threads:[~2026-11-05 19:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 17:57 [PATCH v2] kbuild: move gcc's -Wconstant-logical-operand to W=2 Vineet Gupta
2026-11-05 18:03 ` Nick Desaulniers
2026-11-05 19:45 ` Nathan Chancellor [this message]
2026-11-07  2:23 ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261105194541.GA2668266@ax162 \
    --to=nathan@kernel.org \
    --cc=bp@alien8.de \
    --cc=jakub@redhat.com \
    --cc=julianbraha@gmail.com \
    --cc=justinstitt@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=ndesaulniers@google.com \
    --cc=nsc@kernel.org \
    --cc=peterz@infradead.org \
    --cc=vineet.gupta@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.