The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Naresh Kamboju' <naresh.kamboju@linaro.org>,
	Dan Carpenter <dan.carpenter@linaro.org>
Cc: open list <linux-kernel@vger.kernel.org>,
	"lkft-triage@lists.linaro.org" <lkft-triage@lists.linaro.org>,
	Linux Regressions <regressions@lists.linux.dev>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	"netfilter-devel@vger.kernel.org"
	<netfilter-devel@vger.kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	"Anders Roxell" <anders.roxell@linaro.org>,
	Johannes Berg <johannes.berg@intel.com>,
	"toke@kernel.org" <toke@kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	"kernel@jfarr.cc" <kernel@jfarr.cc>,
	"kees@kernel.org" <kees@kernel.org>
Subject: RE: arm64: include/linux/compiler_types.h:542:38: error: call to '__compiletime_assert_1050' declared with attribute error: clamp() low limit min greater than high limit max_avail
Date: Fri, 6 Dec 2024 02:18:59 +0000	[thread overview]
Message-ID: <bd95d7249ff94e31beb11b3f71a64e87@AcuMS.aculab.com> (raw)
In-Reply-To: <CA+G9fYv5gW1gByakU1yyQ__BoAKWkCcg=vGGyNep7+5p9_2uJA@mail.gmail.com>

From: Naresh Kamboju
> Sent: 05 December 2024 18:42
> 
> On Thu, 5 Dec 2024 at 20:46, Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > Add David to the CC list.
> 
> Anders bisected this reported issue and found the first bad commit as,
> 
> # first bad commit:
>   [ef32b92ac605ba1b7692827330b9c60259f0af49]
>   minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp()

That 'just' changed the test to use __builtin_constant_p() and
thus gets checked after the optimiser has run.

I can paraphrase the code as:
unsigned int fn(unsigned int x)
{
	return clamp(10, 5, x == 0 ? 0 : x - 1);
}
which is never actually called with x <= 5.
The compiler converts it to:
	return x < 0 ? clamp(10, 5, 0) : clamp(10, 5, x);
(Probably because it can see that clamp(10, 5, 0) is constant.)
And then the compile-time sanity check in clamp() fires.

The order of the arguments to clamp is just wrong!

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2024-12-06  2:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-05 14:45 arm64: include/linux/compiler_types.h:542:38: error: call to '__compiletime_assert_1050' declared with attribute error: clamp() low limit min greater than high limit max_avail Naresh Kamboju
2024-12-05 15:16 ` Dan Carpenter
2024-12-05 15:59   ` David Laight
2024-12-05 18:42   ` Naresh Kamboju
2024-12-06  2:18     ` David Laight [this message]
2024-12-11 12:46       ` Bartosz Golaszewski
2024-12-11 13:21         ` Dan Carpenter

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=bd95d7249ff94e31beb11b3f71a64e87@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=anders.roxell@linaro.org \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@linaro.org \
    --cc=johannes.berg@intel.com \
    --cc=kees@kernel.org \
    --cc=kernel@jfarr.cc \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkft-triage@lists.linaro.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=regressions@lists.linux.dev \
    --cc=toke@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox