Re: Unions Redux



Robert Gamble <rgamble99@xxxxxxxxx> wrote:
On Mar 14, 10:32 pm, p...@xxxxxxxxxxxxxxxxxxxxx (Pierre Asselin)

Annex J is informative, not normative,

Indeed it is not and in this case it is simply erroneous. The
sentence you cited is leftover from a previous version of the
Standard, there is no supporting text in the Standard proper.

Has a defect report been filed ?

[ ... ]
So it seems that [Old Wolf's] code has undefined (not just
unspecified) behavior, by 6.2.6.1(5).

I have no idea how you were able to come to that conclusion from
anything you have cited so far. You appear to have come to a
premature conclusion and then tried, unconvincingly, to make the
evidence fit that conclusion.

Not at all. I was tried to prove from 6.2.6 that O.W. can store
and read the bits of a small positive integer interchangeably
through lvalues of type int and unsigned int, but I could only do
it for the signed --> unsigned direction.

My argument doesn't work the other way. 6.2.6.2(5) says:

A valid (non-trap) object representation of a signed integer
type where the sign bit is zero is a valid object representation
of the corresponding unsigned type, and shall represent
the same value.

The opposite is also true, 6.2.5p9:

"The range of nonnegative values of a signed integer type is a
subrange of the corresponding unsigned integer type, and the
representation of the same value in each type is the same."

Indeed. That takes care of the unsigned --> signed direction,
especially in view of footnote 31. So Old Wolf's example is
conforming after all.

This looks like a small defect in the standard. Section 6.2.6.1
opens with: "The representations of all types are unspecified except
as stated in this subclause". I took "subclause" to mean 6.2.6.1
itself but that doesn't work. It could concievably mean all of
6.2.6, which is titled "Representations of types", but not 6.2.5 .
Yet 5.2.5(9) is needed to close a loophole.


I don't know what C++ has to do with this.

It spelled out the concept of a bit-preserving cast, as opposed to
C's value-preserving (for the most part) cast.


--
pa at panix dot com
.



Relevant Pages

  • Re: Accessing via a pointer to 2d array.
    ... >>those padding bits and trapvalues are independent of the actual ... > The C standard, of course. ... Note that the padding bits are part of the object representation. ... > size specified for the bit-field. ...
    (comp.lang.c)
  • Re: getline (reprise)
    ... unsigned char. ... But the mapping from ... an object representation to integer values is not necessarily ... things in the real world, that is, outside of the C standard. ...
    (comp.lang.c)
  • Re: [C++] ceil() outside <cmath>
    ... >>defined in the standard, are only reserved if an associated header is ... > what headers are included by the program." ... If subclause 7.26p1, which uses quite broad wording, is overriding over ... a.c.l.l.c-c++ FAQ: http://ma.rtij.nl/acllc-c++.FAQ.html ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Section from the C standard.
    ... >to ISO C subclause 5.2.4.2.1. ... >I don't have access to the C standard presently, could someone please quote the ... >relevant clause for me. ...
    (comp.lang.c)
  • Re: Section from the C standard.
    ... > to ISO C subclause 5.2.4.2.1. ... The last public draft of the Standard can be downloaded here: ...
    (comp.lang.c)