From: Richard Biener <rguenther@suse.de>
To: Borislav Petkov <bp@alien8.de>
Cc: linux-toolchains@vger.kernel.org, Michael Matz <matz@suse.de>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: older gccs and case labels producing integer constants
Date: Tue, 5 Apr 2022 13:41:09 +0200 (CEST) [thread overview]
Message-ID: <rppnr36-25n9-nors-3p6-3oos06219s8@fhfr.qr> (raw)
In-Reply-To: <YkwdtxNCpiERLFGW@zn.tnic>
[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]
On Tue, 5 Apr 2022, Borislav Petkov wrote:
> On Tue, Apr 05, 2022 at 12:36:58PM +0200, Borislav Petkov wrote:
> > On Tue, Apr 05, 2022 at 12:06:45PM +0200, Richard Biener wrote:
> > > Wird auch mit gcc 11 rejected. Kanns sein dass mit gcc 7 andere
> > > compiler flags genommen werden?
> >
> > Found it:
> >
> > $ gcc -fsanitize=shift -c switch.c
> > switch.c: In function ‘foo’:
> > switch.c:10:7: error: case label does not reduce to an integer constant
> > case (((0xfc08) << 16) | (0x0101)):;
> >
> > $ gcc --version
> > gcc (SUSE Linux) 7.4.1 20190905 [gcc-7-branch revision 275407]
> > Copyright (C) 2017 Free Software Foundation, Inc.
> >
> > Something not fully backported?
>
> Ok, not really:
>
> gcc-10 -fsanitize=shift -c switch.c
> switch.c: In function ‘foo’:
> switch.c:10:7: error: case label does not reduce to an integer constant
> 10 | case (((0xfc08) << 16) | (0x0101)):;
> | ^~~~
>
> BUT!
>
> when more switches are set with gcc-10 (full gcc cmdline from a kernel
> build), then that passes.
>
> But it doesn't pass with gcc-7.
>
> Weird...
As was noted in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66880
this is invalid C99+ but compilers are not required to diagnose that
(you get it diagnosed with -pedantic). -fsanitize=shift exposes
it though since the non-integral-constant gets instrumented.
Richard.
next prev parent reply other threads:[~2022-04-05 12:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-05 9:50 older gccs and case labels producing integer constants Borislav Petkov
2022-04-05 9:58 ` Richard Biener
2022-04-05 10:04 ` Borislav Petkov
2022-04-05 10:06 ` Richard Biener
2022-04-05 10:36 ` Borislav Petkov
2022-04-05 10:45 ` Borislav Petkov
2022-04-05 11:41 ` Richard Biener [this message]
2022-04-07 15:16 ` Borislav Petkov
2022-04-05 11:37 ` Richard Biener
2022-04-06 9:53 ` Jakub Jelinek
2022-04-06 10:04 ` Jakub Jelinek
2022-04-05 12:23 ` Peter Zijlstra
2022-04-05 12:39 ` Michael Matz
2022-04-05 12:53 ` Richard Biener
2022-04-05 13:04 ` Borislav Petkov
2022-04-06 10:13 ` Jakub Jelinek
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=rppnr36-25n9-nors-3p6-3oos06219s8@fhfr.qr \
--to=rguenther@suse.de \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-toolchains@vger.kernel.org \
--cc=matz@suse.de \
/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).