public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x
@ 2023-01-05  8:36 daniel.lundin.mail at gmail dot com
  2023-01-05  8:42 ` [Bug c/108295] " daniel.lundin.mail at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: daniel.lundin.mail at gmail dot com @ 2023-01-05  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108295
           Summary: Free label positions shouldn't be available outside
                    -std=c2x
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel.lundin.mail at gmail dot com
  Target Milestone: ---

The new C23 features introduced in gcc 11.0.0 appears to be inconsistently
deactivated when picking some other version than -std=c2x.

The new C23 feature "Free positioning of labels inside compound statements"
appears to be active even with -std=c17 or the default gnu17 is picked. Unlike
other C23 features introduced in the same version 11 release, which are
correctly activated when using -std=c2x or otherwise inactivated.

For example gcc treats true/false as bool when activating -std=c2x but treats
them as int when older C versions are used. Free positioning of labels should
behave just in the same manner.

See attached example.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
@ 2023-01-05  8:42 ` daniel.lundin.mail at gmail dot com
  2023-01-05  8:53 ` schwab@linux-m68k.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.lundin.mail at gmail dot com @ 2023-01-05  8:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Daniel Lundin <daniel.lundin.mail at gmail dot com> ---
Created attachment 54193
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54193&action=edit
Correctly working true/false vs incorrectly free position of label

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
  2023-01-05  8:42 ` [Bug c/108295] " daniel.lundin.mail at gmail dot com
@ 2023-01-05  8:53 ` schwab@linux-m68k.org
  2023-01-05  8:55 ` daniel.lundin.mail at gmail dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: schwab@linux-m68k.org @ 2023-01-05  8:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
Free positioning of labels inside compound statements doesn't affect correctly
written programs.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
  2023-01-05  8:42 ` [Bug c/108295] " daniel.lundin.mail at gmail dot com
  2023-01-05  8:53 ` schwab@linux-m68k.org
@ 2023-01-05  8:55 ` daniel.lundin.mail at gmail dot com
  2023-01-05  9:00 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.lundin.mail at gmail dot com @ 2023-01-05  8:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Daniel Lundin <daniel.lundin.mail at gmail dot com> ---
(In reply to Andreas Schwab from comment #2)
> Free positioning of labels inside compound statements doesn't affect
> correctly written programs.

No but until C23, the compiler should report an error for incorrect syntax when
they aren't. For example when declaring a variable inside a case statement
without using {} compound statements.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (2 preceding siblings ...)
  2023-01-05  8:55 ` daniel.lundin.mail at gmail dot com
@ 2023-01-05  9:00 ` pinskia at gcc dot gnu.org
  2023-01-05  9:18 ` daniel.lundin.mail at gmail dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-05  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-01-05
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Try -pedantic-errors.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (3 preceding siblings ...)
  2023-01-05  9:00 ` pinskia at gcc dot gnu.org
@ 2023-01-05  9:18 ` daniel.lundin.mail at gmail dot com
  2023-01-05  9:27 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.lundin.mail at gmail dot com @ 2023-01-05  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Daniel Lundin <daniel.lundin.mail at gmail dot com> ---
(In reply to Andrew Pinski from comment #4)
> Try -pedantic-errors.

Yes I already did and then the error appears. But that would imply that this is
a non-standard GNU extension and not an upcoming standard C23 feature, which
still doesn't seem correct. 

If the intention was to add this as a GNU extension until formal release of
C23, then the use of such GNU extensions will behave inconsistently between gcc
<10.4 and gcc >11.0 when using the same compiler options. And I don't think
that's documented anywhere either.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (4 preceding siblings ...)
  2023-01-05  9:18 ` daniel.lundin.mail at gmail dot com
@ 2023-01-05  9:27 ` pinskia at gcc dot gnu.org
  2023-01-05  9:31 ` daniel.lundin.mail at gmail dot com
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-05  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Daniel Lundin from comment #5)
> (In reply to Andrew Pinski from comment #4)
> > Try -pedantic-errors.
> 
> Yes I already did and then the error appears. But that would imply that this
> is a non-standard GNU extension and not an upcoming standard C23 feature,
> which still doesn't seem correct. 
> 
> If the intention was to add this as a GNU extension until formal release of
> C23, then the use of such GNU extensions will behave inconsistently between
> gcc <10.4 and gcc >11.0 when using the same compiler options. And I don't
> think that's documented anywhere either.

https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Mixed-Labels-and-Declarations.html#Mixed-Labels-and-Declarations

Compared to
https://gcc.gnu.org/onlinedocs/gcc-9.5.0/gcc/Mixed-Declarations.html#Mixed-Declarations

Is definitely documented.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (5 preceding siblings ...)
  2023-01-05  9:27 ` pinskia at gcc dot gnu.org
@ 2023-01-05  9:31 ` daniel.lundin.mail at gmail dot com
  2023-01-05  9:35 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.lundin.mail at gmail dot com @ 2023-01-05  9:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Daniel Lundin <daniel.lundin.mail at gmail dot com> ---
(In reply to Andrew Pinski from comment #6)
> (In reply to Daniel Lundin from comment #5)
> > (In reply to Andrew Pinski from comment #4)
> > > Try -pedantic-errors.
> > 
> > Yes I already did and then the error appears. But that would imply that this
> > is a non-standard GNU extension and not an upcoming standard C23 feature,
> > which still doesn't seem correct. 
> > 
> > If the intention was to add this as a GNU extension until formal release of
> > C23, then the use of such GNU extensions will behave inconsistently between
> > gcc <10.4 and gcc >11.0 when using the same compiler options. And I don't
> > think that's documented anywhere either.
> 
> https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Mixed-Labels-and-Declarations.
> html#Mixed-Labels-and-Declarations
> 
> Compared to
> https://gcc.gnu.org/onlinedocs/gcc-9.5.0/gcc/Mixed-Declarations.html#Mixed-
> Declarations
> 
> Is definitely documented.

Fair enough but GNU C mode is -std=gnu17 (the default setting), not -std=c17.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (6 preceding siblings ...)
  2023-01-05  9:31 ` daniel.lundin.mail at gmail dot com
@ 2023-01-05  9:35 ` pinskia at gcc dot gnu.org
  2023-01-05  9:42 ` daniel.lundin.mail at gmail dot com
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-05  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
"When a base standard is specified, the compiler accepts all programs following
that standard plus those using GNU extensions that do not contradict it."

Wrong again.
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/C-Dialect-Options.html#index-std-1

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (7 preceding siblings ...)
  2023-01-05  9:35 ` pinskia at gcc dot gnu.org
@ 2023-01-05  9:42 ` daniel.lundin.mail at gmail dot com
  2023-01-05  9:50 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: daniel.lundin.mail at gmail dot com @ 2023-01-05  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Daniel Lundin <daniel.lundin.mail at gmail dot com> ---
(In reply to Andrew Pinski from comment #8)
> "When a base standard is specified, the compiler accepts all programs
> following that standard plus those using GNU extensions that do not
> contradict it."
> 
> Wrong again.
> https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/C-Dialect-Options.html#index-
> std-1

In this case the GNU extension does contradict the ISO 9899:2018 standard. A
conforming compiler is required to issue a diagnostic (as per 5.1.1.3) upon
spotting a violation of the syntax in 6.8.1.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (8 preceding siblings ...)
  2023-01-05  9:42 ` daniel.lundin.mail at gmail dot com
@ 2023-01-05  9:50 ` pinskia at gcc dot gnu.org
  2023-01-05  9:54 ` jakub at gcc dot gnu.org
  2023-01-05  9:55 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-05  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
By conflicting means rejection of correct code. Like for an example the use of
the ident non reserved unix, etc.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (9 preceding siblings ...)
  2023-01-05  9:50 ` pinskia at gcc dot gnu.org
@ 2023-01-05  9:54 ` jakub at gcc dot gnu.org
  2023-01-05  9:55 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-05  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Daniel Lundin from comment #9)
> In this case the GNU extension does contradict the ISO 9899:2018 standard. A
> conforming compiler is required to issue a diagnostic (as per 5.1.1.3) upon
> spotting a violation of the syntax in 6.8.1.

In such understanding all extensions would contradict the standard, extensions
are when some otherwise invalid source is given a meaning, which is this case
too.
Even in C++ we often enable features of a newer standard in older ones as long
as they don't conflict with valid syntax, just with pedantic warnings/errors. 
It is possible
if the new feature has a new syntax which is invalid in the old standard, so
e.g. structured bindings can be accepted in older standards with pedantic
warnings/errors just fine because in older standards it was always invalid
syntax.  Compare that to features where say the behavior of some construct
changes with a newer standard version, that one obviously can't be treated that
way.
And -pedantic/-pedantic-errors are the options to request pedantic warnings or
errors.

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

* [Bug c/108295] Free label positions shouldn't be available outside -std=c2x
  2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
                   ` (10 preceding siblings ...)
  2023-01-05  9:54 ` jakub at gcc dot gnu.org
@ 2023-01-05  9:55 ` pinskia at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-05  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #10)
> By conflicting means rejection of correct code. Like for an example the use
> of the ident non reserved unix, etc.

The documentation even mentions that. You only read the snippet of what I
copied rather than reading the whole thing.

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

end of thread, other threads:[~2023-01-05  9:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05  8:36 [Bug c/108295] New: Free label positions shouldn't be available outside -std=c2x daniel.lundin.mail at gmail dot com
2023-01-05  8:42 ` [Bug c/108295] " daniel.lundin.mail at gmail dot com
2023-01-05  8:53 ` schwab@linux-m68k.org
2023-01-05  8:55 ` daniel.lundin.mail at gmail dot com
2023-01-05  9:00 ` pinskia at gcc dot gnu.org
2023-01-05  9:18 ` daniel.lundin.mail at gmail dot com
2023-01-05  9:27 ` pinskia at gcc dot gnu.org
2023-01-05  9:31 ` daniel.lundin.mail at gmail dot com
2023-01-05  9:35 ` pinskia at gcc dot gnu.org
2023-01-05  9:42 ` daniel.lundin.mail at gmail dot com
2023-01-05  9:50 ` pinskia at gcc dot gnu.org
2023-01-05  9:54 ` jakub at gcc dot gnu.org
2023-01-05  9:55 ` 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).