Messages in this thread Patch in this message | | | Date | Thu, 7 Apr 2022 17:16:40 +0200 | From | Borislav Petkov <> | Subject | Re: older gccs and case labels producing integer constants |
| |
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
| |