• Re: UB or not UB? was: On Undefined Behavior

    From Tim Rentsch@tr.17687@z991.linuxsc.com to comp.lang.c on Sun Mar 1 22:53:28 2026
    From Newsgroup: comp.lang.c

    Andrey Tarasevich <noone@noone.net> 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.
    --- Synchronet 3.21c-Linux NewsLink 1.2