https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65892

--- Comment #61 from Davin McCall <davmac at davmac dot org> ---
(In reply to James Kuyper Jr. from comment #59)
> (In reply to Davin McCall from comment #56)
> > (In reply to James Kuyper Jr. from comment #55)
> > > The problem is, you're using a statement that the access must occur via a
> > > union, with the implication that the code in question does not access the
> > > member through the union.
> > 
> > If "via a union" allows that at some point that the address of a union
> > member was taken and that pointer is then dereferenced, and type punning via
> > a union is allowed (as is implied by another footnote in the same section),
> > then:
> 
> Footnote 95 is the only one I can find which allows type punning via a union
> - is that the one you're referring to? Footnote 95 makes absolutely no use
> of the word "via". It says, quite explicitly, "the member used to read the
> contents of a union", and therefore can't apply when not directly using an
> actual member to read it.

Since footnote 95 is a footnote, and therefore non-normative, so actual text
that would limit type punning to only direct union member access would have to
appear in the normative text, but doesn't. In an expression "u.a" where u is a
union object, the result "is an lvalue if" (u) "is an lvalue" (assume for this
example that it is) and also the value is "that of the named member" (a). To
apply the "&" operator to that (as in "&u.a"), then "the result is a pointer to
the object or function designated by its operand". When I then de-reference
that pointer, "the result is an lvalue designating the object", exactly as the
result of the member access operator. When the lvalue is used as per 6.3.2.1 it
is "converted to the value stored in the designated object" which, if it is
referring to a member object, seems to me to be the same as saying that it is
converted to the value "of the named member", as with direct member access.

Since the rest of my points hinged on the idea that is inconsistent to believe
that the clause regarding the common initial sequence applies universally while
type punning requires direct/immediate use of the union, and you disagree with
that tenet, then I don't see a need to go through the other points one by one
and I will let the matter rest unless you would like to discuss it privately
via email (to avoid making even more noise here).

Reply via email to