Re: older gccs and case labels producing integer constants

From: Borislav Petkov
Date: Tue Apr 05 2022 - 19:53:10 EST


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...

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette