[Bug c/111526] New: inconsistent handling of declaration after label
P at draigBrady dot com
gcc-bugzilla@gcc.gnu.org
Thu Sep 21 18:02:35 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526
Bug ID: 111526
Summary: inconsistent handling of declaration after label
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: P at draigBrady dot com
Target Milestone: ---
Created attachment 55963
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55963&action=edit
coreutils fix for non gcc >= 11
Ever since https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8b7a9a24
declarations after labels are allowed by default,
and only disabled with -pedantic etc.
I.e. the following simple code compiles on gcc >= 11,
but will fail when tried to be compiled with gcc <= 10, or clang for e.g.
This is exacerbated by the fact there is no compiler option
to avoid the issue on gcc <= 10 or clang,
as that code is explicitly disallowed by C11 and earlier.
int f(int x) { switch (x) { case 1: int i=f(x); } return 0; }
There is also a more subtle related issue
(which I haven't fully reduced but can easily reproduce),
where the warning will NOT fire even with -Wpedantic on gcc 13 at least.
If one compiles GNU coreutils with the attached commit reverted,
and with -Wpedantic on newer gcc, it will _NOT_ issue a warning.
More information about the Gcc-bugs
mailing list