Sujet : Re: "A diagram of C23 basic types"
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 14. Apr 2025, 10:10:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <865xj79khz.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Keith Thompson <Keith.S.Thompson+
u@gmail.com> writes:
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
[...]
>
Trailing commas in argument lists and/or parameter lists
could be accepted as an extension, even without giving a
diagnostic as I read the C standard, but implementations
are certainly within their rights to reject them.
>
I believe a diagnotic is required.
>
C17 5.1.1.3:
>
A conforming implementation shall produce at least one
diagnostic message (identified in an implementation-defined
manner) if a preprocessing translation unit or translation
unit contains a violation of any syntax rule or constraint,
even if the behavior is also explicitly specified as undefined
or implementation-defined.
>
A trailing comma on an argument or parameter list is a violation
of a syntax rule.
I believe a diagnostic is not required, because the C standard
explicitly allows extensions. If such diagnostics were required
even for constructions that are part of extensions, then there is no
reason to allow extensions, because whatever behavior is desired
could be done anyway, under the freedom granted by undefined
behavior. It would be stupid to explicitly grant permission to do
something if it could be done anyway without the permission. And
the people who wrote the C standard are not stupid.