Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: UB or not UB? was: On Undefined Behavior
Date: Sun, 01 Mar 2026 22:53:28 -0800
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <868qcag1sn.fsf@linuxsc.com>
References: <10j6qdt$3q9n4$1@dont-email.me> <20260112162857.00003dd8@yahoo.com> <10k360j$2epre$1@dont-email.me> <20260112193652.000051d0@yahoo.com> <10k5qr3$385fd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Mon, 02 Mar 2026 06:53:31 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="879346d16fc7c1cd3f18baf5c462c148"; logging-data="970912"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bmhnzcYk8RM795xqmOZeeIK2Bt4HMFEw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ZaNUliMbMMZQ9Zu9IFHG61AruBg= sha1:dsvNx29Mlec9YgyJhifNLtVd2X8=
Xref: csiph.com comp.lang.c:396720
Andrey Tarasevich writes:
> On Mon 1/12/2026 9:36 AM, Michael S wrote:
>
>> But I was interested in the "opinion" of C Standard rather than of gcc
>> compiler.
>> Is it full nasal UB or merely "implementation-defined behavior"?
>
> It is full nasal UB per the standard. And, of course, it is as
> "implementation-defined" as any other UB in a sense that the standard
> permits implementations to _extend_ the language in any way they
> please, as long as they don't forget to issue diagnostics when
> diagnostics are required (by the standard).
There are two schools of thought on that question. For example, if
an implementation extends the ISO standard by adding a syntax rule,
then using a construct following the added rule does not violate the
syntax and hence no diagnostic is required. Conversely, it would be
silly for the C standard to say extensions are allowed if what the
extensions do could be done anyway under the umbrella of undefined
behavior (after a diagnostic is issued). The point of saying the
standard allows extensions is so that an implementation may decline
to issue a diagnostic in certain cases where one would otherwise be
required.
I'm not claiming that this view is the only view possible, only that
it is consistent with what is said in the C standard.