From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Stafford Horne <shorne@gmail.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: Issue with inline functions and switch statements
Date: Tue, 4 Aug 2020 22:25:47 +0200 [thread overview]
Message-ID: <20200804202547.vqeihhonjsikxtio@ltop.local> (raw)
In-Reply-To: <20200803142903.GK80756@lianli.shorne-pla.net>
On Mon, Aug 03, 2020 at 11:29:03PM +0900, Stafford Horne wrote:
> Hello,
Hi,
> I am the maintainer of the OpenRISC architecture linux port, and recently have
> started to look at the kbuild sparse errors.
>
> The Linux kernel kbuild process is reporting sparse error:
>
> net/dccp/proto.c: note: in included file (through include/asm-generic/atomic.h, arch/openrisc/include/asm/atomic.h, include/linux/atomic.h, ...):
> arch/openrisc/include/asm/cmpxchg.h:101:29: sparse: sparse: shift too big (32) for type int
>
> Example: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2256733.html
>
> I have traced this down to the case like the below.
>
> It reports an unexpected warning:
>
> simple_test.c:7:18: warning: shift too big (32) for type int
>
> This is not pssible because size = 4 should never call shift_small.
>
> I have debugged sparse when this is running and it seems that when checking the switch
> cases it evaluates all cases, and thinks size = 4 is possible. I am not sure if this
> is a problem with the sparse front end of the check logic.
>
> Can you help?
Sure. The problem is sparse sees the expression '1 << (4 * 8)'
and warns about it before it can know it will never be evaluated.
The exact same problem happens with an even simpler example:
int foo(void)
{
return 0;
return 1 << 32;
}
I have an old series for this problem, I would just need to dust off.
It shouldn't take much time, probably just a few days, maximum 10
(but I vaguely remember there was a nasty complication, which is
why it's still pending).
Best regards,
-- Luc
prev parent reply other threads:[~2020-08-04 20:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-03 14:29 Issue with inline functions and switch statements Stafford Horne
2020-08-04 20:25 ` Luc Van Oostenryck [this message]
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=20200804202547.vqeihhonjsikxtio@ltop.local \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=shorne@gmail.com \
/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).