Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: tcc - first impression. Was: Baby X is bor nagain
Date: Tue, 02 Jul 2024 06:47:35 -0700
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <86v81nc3d4.fsf@linuxsc.com>
References: <20240624160941.0000646a@yahoo.com> <20240624181006.00003b94@yahoo.com> <20240625113616.000075e0@yahoo.com> <87ed8jnbmf.fsf@bsb.me.uk> <867ceadtih.fsf@linuxsc.com> <20240701200924.00003d9a@yahoo.com> <87zfr0wzpt.fsf@nosuchdomain.example.com> <20240702115448.00002025@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 02 Jul 2024 15:47:38 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a921cf177a5ef0d729c498a18e4544b7";
logging-data="1759734"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19R13Nq8MP80FnF29PH6SzK4ZzZQ/7K6Xc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:jnZE/Wd47Y3u8yP/E+QVGd1E+mg=
sha1:EGrJjYpda25x0XqOBkCUTAaxHbA=
Bytes: 3880
Michael S writes:
> On Mon, 01 Jul 2024 14:48:30 -0700
> Keith Thompson wrote:
>
>> Michael S 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.