Sujet : Re: tcc - first impression. Was: Baby X is bor nagain
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 02. Jul 2024, 14:47:35
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86v81nc3d4.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Michael S <
already5chosen@yahoo.com> writes:
On Mon, 01 Jul 2024 14:48:30 -0700
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
Michael S <already5chosen@yahoo.com> writes:
[...]
4.2. Code like below does not compile. I don't know whether it is
legal 'C' or not,
but gcc, clang and MSVC compilers accept it o.k.
label:int bar;
>
That's a syntax error in versions of C up to and including C17. C23
allows labels on declarations. [...]
>
Now I paid attention that my statement above is incorrect: clang does
*not* accept it.
gcc accepts it, for all supported standards, but with -Wpedantic
it issues the warning for all standards except c2x.
MSVC (17 and 19, but not 13) accepts it and issues no warning even with
maximal warning level.
>
clang and tcc are right. I find no advantages in this sort of rightness.
Is your objection to a diagnostic message being issued, or is
your objection to the construct causing the compilation to fail?
I would call what the more recent MSVC versions do as being
*wrong*. The C standard requires a diagnostic.
I would not call what clang and tcc do as being right. Their
behavior conforms to the C standard, but giving an unavoidable
error is kind of obnoxious.
The reported behavior for gcc -pedantic is okay. It would be
nice if there were a separate option to allow the non-standard
labels to be accepted without giving a warning. Also it would
be better if -std=cNN implied -pedantic (presumably with a way
to change that, selectively if possible); historically that
choice might have been okay, but for at least the last 15 years
it has been a disservice to the C community. I should note
specifically that it is -pedantic that should be implied, and
not -pedantic-error.
More generally, the default behavior for any non-conforming but
often used construct should be a warning, not an error (unless of
course -Werror has been specified). I understand the motivation
to give an error in the case of a syntax violation, but forcing
any syntax violation to be an error is still a poor choice, not
just for the compiler but also for the C community generally.
Just my opinions, in case that needs saying.