Re: Unions Redux
- From: pa@xxxxxxxxxxxxxxxxxxxxx (Pierre Asselin)
- Date: Fri, 16 Mar 2007 02:24:25 +0000 (UTC)
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
.
- References:
- Unions Redux
- From: Old Wolf
- Re: Unions Redux
- From: Pierre Asselin
- Re: Unions Redux
- From: Robert Gamble
- Unions Redux
- Prev by Date: Re: Unions Redux
- Next by Date: Re: strtok
- Previous by thread: Re: Unions Redux
- Next by thread: Re: Unions Redux
- Index(es):
Relevant Pages
|