Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #2761

Re: Union C++ standard

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.compilers
Subject Re: Union C++ standard
Date 2021-11-29 14:32 -0800
Organization None to speak of
Message-ID <21-11-014@comp.compilers> (permalink)
References <21-11-004@comp.compilers> <21-11-008@comp.compilers> <21-11-009@comp.compilers> <21-11-010@comp.compilers> <21-11-012@comp.compilers>

Show all headers | View raw


Kaz Kylheku <480-992-1380@kylheku.com> writes:
> On 2021-11-28, David Brown <david.brown@hesbynett.no> wrote:
>> On 28/11/2021 13:51, Derek Jones wrote:
>>> David,
>>>
>>>> In C, type-punning via unions is allowed (i.e., fully defined behaviour
>>>
>>> That is not true.  Writing into one member and then reading from
>>> another member is undefined behavior.
>>
>> No, it is correct.  It would be helpful if you looked at the full
>> published standards, or (as most people do, since they are free) the
>> final pre-publishing drafts.  In particular, they contain the footnotes
>> that appear to be missing in the format you linked here.  Footnotes are
>> not part of the normative text, but are added for clarification.
>
> Not being normative means that anything that looks like a requirement
> that is in a footnote is not actually a requirement.
>
> Footnotes can only clarify requirements that are not themselves in a
> foonote; they can't add new requirements.
>
> If you cannot infer the existence of a requirement while ignoring all
> foonotes and examples, it isn't there.
>
>> These quotations are from C18 (draft N2346), which is the current C
>> standard (until C23 is finalised).  They have not changed since C99,
>> when the footnote was added without a change to the normative text.

I don't think N2346 is a draft of "C18".  The page headers say:

    N2346      working draft — March 13, 2019      ISO/IEC 9899:202x (E)

The current C standard is usually referred to as "C17"; it's a minor
update to C11.  Work is in progress on C2X, which will supersede C17.

> I have a copy of C99 (the final thing from ANSI, not a draft); I do not
> see any such footnote; the paragraph has no footnotes.

(It was published by ISO.  ANSI adopted it and sold copies.)

The footnote does not appear in the published 1999 ISO C standard.  It
was added by Technical Corrigendum 3, published in 2007 (and therefore
in the N1256 draft, which includes the 1999 standard with the three
Technical Corrigenda merged into it).  As far as ISO is concerned, it's
part of C99 -- and of later editions of the standard, which have
superseded C99.

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */
[I think this horse has been beaten about all it needs to.  And
it reminds us that just because C says something is defined does
not mean it's portable or that the results are easily predictable.

This is hardly the only place, e.g., the exciting range of things
that might or might not happen if the result of an integer operation
doesn't fit in its result type.  It might wrap, it might overflow,
it might saturate.  Or it might not. -John]

Back to comp.compilers | Previous | NextPrevious in thread | Find similar


Thread

Union C++ standard Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2021-11-25 11:11 +0100
  Re: Union C++ standard Kaz Kylheku <480-992-1380@kylheku.com> - 2021-11-26 18:06 +0000
  Re: Union C++ standard gah4 <gah4@u.washington.edu> - 2021-11-26 12:16 -0800
  Re: Union C++ standard David Brown <david.brown@hesbynett.no> - 2021-11-27 16:59 +0100
    Re: Union C++ standard Derek Jones <derek@NOSPAM-knosof.co.uk> - 2021-11-28 12:51 +0000
      Re: Union C++ standard David Brown <david.brown@hesbynett.no> - 2021-11-28 19:00 +0100
        Re: Union C++ standard Derek Jones <derek@NOSPAM-knosof.co.uk> - 2021-11-29 00:09 +0000
          Re: Union C++ standard David Brown <david.brown@hesbynett.no> - 2021-11-29 21:00 +0100
            Re: Union C++ standard Derek Jones <derek@NOSPAM-knosof.co.uk> - 2021-11-30 00:46 +0000
              Re: Union C++ standard George Neuner <gneuner2@comcast.net> - 2021-11-30 17:18 -0500
                Re: Union C++ standard terminology Derek Jones <derek@knosof.co.uk> - 2021-12-01 13:35 +0000
              Re: Union C++ standard David Brown <david.brown@hesbynett.no> - 2021-11-30 23:24 +0100
        Re: Union C++ standard Kaz Kylheku <480-992-1380@kylheku.com> - 2021-11-29 16:39 +0000
          Re: Union C++ standard Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-11-29 14:32 -0800

csiph-web