From: Borislav Petkov <bp@alien8.de>
To: Richard Biener <rguenther@suse.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: Thu, 7 Apr 2022 17:16:40 +0200 [thread overview]
Message-ID: <Yk8AWEgdej5OrJfT@zn.tnic> (raw)
In-Reply-To: <rppnr36-25n9-nors-3p6-3oos06219s8@fhfr.qr>
On Tue, Apr 05, 2022 at 01:41:09PM +0200, Richard Biener wrote:
> 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.
Right, just to close this: I was still unsure which of the cmdline
options would cause it and bisected the kernel (big fat box can build
allmodconfigs in no time :)).
The single change which fixes the whole build is
---
diff --git a/Makefile b/Makefile
index 8c7de9a72ea2..3582089cfeb6 100644
--- a/Makefile
+++ b/Makefile
@@ -523,7 +523,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
-Werror=implicit-function-declaration -Werror=implicit-int \
-Werror=return-type -Wno-format-security \
- -std=gnu11
+ -std=gnu89
KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
with that
gcc (SUSE Linux) 7.4.1 20190905 [gcc-7-branch revision 275407]
but as we saw, only -std=gnu11 alone doesn't cause it:
$ gcc -std=gnu11 -o switch.o switch.c
$
And so we had the -fsanitize=shift already enabled since 2020 in the
kernel build and the gnu11 change then triggered the undefined behavior
due to the -fsanitize instrumentation as it was already explained:
$ gcc -std=gnu11 -fsanitize=shift -o switch.o 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)):;
^~~~
Ok, now I can sleep at night again.
:-)))
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2022-04-07 15:16 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
2022-04-07 15:16 ` Borislav Petkov [this message]
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=Yk8AWEgdej5OrJfT@zn.tnic \
--to=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-toolchains@vger.kernel.org \
--cc=matz@suse.de \
--cc=rguenther@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