From: Arnd Bergmann <arnd@arndb.de>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <christian.brauner@ubuntu.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>
Subject: Re: [PATCH] bitops: avoid clang shift-count-overflow warnings
Date: Tue, 5 May 2020 17:32:52 +0200 [thread overview]
Message-ID: <CAK8P3a2pXZGbFvXpD5D4trGjxaie_NYi4hhUyYmKmv9A_HfRdA@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VfmvXotH+NRt_YnNQW8O38Gas+ZfLH00jfhytM8w7ka3w@mail.gmail.com>
On Tue, May 5, 2020 at 4:08 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Tue, May 5, 2020 at 4:58 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > Clang normally does not warn about certain issues in inline functions when
> > it only happens in an eliminated code path. However if something else
> > goes wrong, it does tend to complain about the definition of hweight_long()
> > on 32-bit targets:
>
> Shouldn't it be fixed in CLang?
>
> > include/linux/bitops.h:75:41: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
> > return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
> > ^~~~~~~~~~~~
>
> sizeof(w) is compile-time constant. It can easily drop the second part
> without even looking at it.
>
> > Adding an explicit cast to __u64 avoids that warning and makes it easier
> > to read other output.
>
> Looks like papering over the real issue.
I'm not sure if there is anything to be done about it in clang, since it
always does syntactic analysis before dead-code elimination by design.
It is a bit odd though that it only prints the warning sometimes, but
I suspect this is also something that works as designed. Maybe someone
on the clang-built-linux list knows more about the background.
Arnd
next prev parent reply other threads:[~2020-05-05 15:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 13:54 [PATCH] bitops: avoid clang shift-count-overflow warnings Arnd Bergmann
2020-05-05 14:01 ` Christian Brauner
2020-05-05 14:08 ` Andy Shevchenko
2020-05-05 15:32 ` Arnd Bergmann [this message]
2020-05-05 15:36 ` Nick Desaulniers
2020-05-05 15:44 ` Arnd Bergmann
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=CAK8P3a2pXZGbFvXpD5D4trGjxaie_NYi4hhUyYmKmv9A_HfRdA@mail.gmail.com \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=christian.brauner@ubuntu.com \
--cc=clang-built-linux@googlegroups.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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;
as well as URLs for NNTP newsgroup(s).