public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111526] New: inconsistent handling of declaration after label
@ 2023-09-21 18:02 P at draigBrady dot com
  2023-09-21 18:10 ` [Bug c/111526] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: P at draigBrady dot com @ 2023-09-21 18:02 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/111526] inconsistent handling of declaration after label
  2023-09-21 18:02 [Bug c/111526] New: inconsistent handling of declaration after label P at draigBrady dot com
@ 2023-09-21 18:10 ` pinskia at gcc dot gnu.org
  2023-09-21 18:13 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 18:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-09-21
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is expected behavior.

 -Wc11-c2x-compat warns also ...


>(which I haven't fully reduced but can easily reproduce),


We need a testcase where you think it should warn but does not ...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/111526] inconsistent handling of declaration after label
  2023-09-21 18:02 [Bug c/111526] New: inconsistent handling of declaration after label P at draigBrady dot com
  2023-09-21 18:10 ` [Bug c/111526] " pinskia at gcc dot gnu.org
@ 2023-09-21 18:13 ` pinskia at gcc dot gnu.org
  2023-09-21 18:26 ` P at draigBrady dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 18:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Can you attach the original preprocessed source where you get no warning and
you think you should. Others can reduce it.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/111526] inconsistent handling of declaration after label
  2023-09-21 18:02 [Bug c/111526] New: inconsistent handling of declaration after label P at draigBrady dot com
  2023-09-21 18:10 ` [Bug c/111526] " pinskia at gcc dot gnu.org
  2023-09-21 18:13 ` pinskia at gcc dot gnu.org
@ 2023-09-21 18:26 ` P at draigBrady dot com
  2023-09-21 18:28 ` P at draigBrady dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: P at draigBrady dot com @ 2023-09-21 18:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526

--- Comment #3 from Pádraig Brady <P at draigBrady dot com> ---
Created attachment 55964
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55964&action=edit
coreutils tail.c compilation unit

This should warn with -Wpedantic, but doesn't on gcc 13

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/111526] inconsistent handling of declaration after label
  2023-09-21 18:02 [Bug c/111526] New: inconsistent handling of declaration after label P at draigBrady dot com
                   ` (2 preceding siblings ...)
  2023-09-21 18:26 ` P at draigBrady dot com
@ 2023-09-21 18:28 ` P at draigBrady dot com
  2023-09-21 18:43 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: P at draigBrady dot com @ 2023-09-21 18:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526

--- Comment #4 from Pádraig Brady <P at draigBrady dot com> ---
Interestingly, gcc 13 _does_ warn with -Wc11-c2x-compat,
but does not warn with -Wpedantic

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/111526] inconsistent handling of declaration after label
  2023-09-21 18:02 [Bug c/111526] New: inconsistent handling of declaration after label P at draigBrady dot com
                   ` (3 preceding siblings ...)
  2023-09-21 18:28 ` P at draigBrady dot com
@ 2023-09-21 18:43 ` pinskia at gcc dot gnu.org
  2023-09-21 18:43 ` pinskia at gcc dot gnu.org
  2023-09-21 18:45 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 18:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, somehow the value of warn_c11_c2x_compat is being changed from -1 to 0 ...
and not being changed back, maybe a __extension__ is happening incorrectly.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/111526] inconsistent handling of declaration after label
  2023-09-21 18:02 [Bug c/111526] New: inconsistent handling of declaration after label P at draigBrady dot com
                   ` (4 preceding siblings ...)
  2023-09-21 18:43 ` pinskia at gcc dot gnu.org
@ 2023-09-21 18:43 ` pinskia at gcc dot gnu.org
  2023-09-21 18:45 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 18:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |UNCONFIRMED
     Ever confirmed|1                           |0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/111526] inconsistent handling of declaration after label
  2023-09-21 18:02 [Bug c/111526] New: inconsistent handling of declaration after label P at draigBrady dot com
                   ` (5 preceding siblings ...)
  2023-09-21 18:43 ` pinskia at gcc dot gnu.org
@ 2023-09-21 18:45 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 18:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually wait:
# 3997 "./lib/config.h"
#pragma GCC diagnostic ignored "-Wpedantic"

coreutils's config.h explictly disables -Wpedantic ...

So not a bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-21 18:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-21 18:02 [Bug c/111526] New: inconsistent handling of declaration after label P at draigBrady dot com
2023-09-21 18:10 ` [Bug c/111526] " pinskia at gcc dot gnu.org
2023-09-21 18:13 ` pinskia at gcc dot gnu.org
2023-09-21 18:26 ` P at draigBrady dot com
2023-09-21 18:28 ` P at draigBrady dot com
2023-09-21 18:43 ` pinskia at gcc dot gnu.org
2023-09-21 18:43 ` pinskia at gcc dot gnu.org
2023-09-21 18:45 ` pinskia at gcc dot gnu.org

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 read-only IMAP folder(s) and NNTP newsgroup(s).