From 9059091245548062952
X-Google-Thread: f78e5,1130823ffefc6ebe
X-Google-Thread: fc772,1130823ffefc6ebe
X-Google-Attributes: gidf78e5,gidfc772,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed-east.nntpserver.com!nntpserver.com!newsfeed1.sea.pnap.net!newsfeed2.sea.pnap.net!newsfeed.pnap.net!brmea-news-1.sun.com!news1nwk.sfbay.sun.com!taumet!clamage
From: glenlow@pixelglow.com (Glen Low)
Newsgroups: comp.std.c++,comp.lang.c++.moderated
Subject: Re: Unions up in arms!
Date: Mon, 13 Sep 2004 15:37:26 +0000 (UTC)
Organization: http://groups.google.com
Lines: 53
Sender: cppmods@netlab.cs.rpi.edu
Approved: stephen.clamage@sun.com (comp.std.c++)
Message-ID: <9215d7ac.0409111529.ab7cefa@posting.google.com>
References: <9215d7ac.0409081832.4ab088d6@posting.google.com>
 <uhj3k0hqebguh4o2u1i7va52dm0n4bjlvh@4ax.com>
NNTP-Posting-Host: taumet.sfbay.sun.com
Content-Type: TEXT/PLAIN
X-Trace: news1nwk.SFbay.Sun.COM 1095089846 24028 129.146.79.208 (13 Sep 2004 15:37:26 GMT)
X-Complaints-To: usenet@news1nwk.sfbay.sun.com
NNTP-Posting-Date: Mon, 13 Sep 2004 15:37:26 +0000 (UTC)
X-Original-NNTP-posting-date: Mon, 13 Sep 2004 10:34:46 +0000 (UTC)
Delivered-to: std-c++@ucar.edu
X-Original-Date: Sat, 11 Sep 2004 16:29:27 -0700
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
 iQBVAwUAQUV4jUHMCo9UcraBAQFcJAH/Wl8FlrHDmz0ulwfrrtrwbVYXdsOKMExO
 hOD8w13Zpobg0obWEIik0KvEsIdcadqjvSiIhGjfmuQ9V22tLGj5xg==                =syNE
X-Approved-For-Group: francis.moderator@robinton.demon.co.uk
 comp.lang.c++.moderated
Original-recipient: rfc822;clamage@mpk-mail1.SFBay.Sun.COM
Originator: clamage@taumet
Xref: g2news1.google.com comp.std.c++:2581 comp.lang.c++.moderated:8068


 > Aren't you making a fairly big assumption?
 > What if sizeof(int) != sizeof(float)?

Let's assume that it is so.

 > >And finally, what does "including, recursively, a member of a
 > >subaggregate or contained union" mean?

Well, interpretation A was that:

an object of type int can be accessed by a lvalue of type union { int
i; float f }; and also an lvalue of type union { union { int i; float
f}; float g; };

But that doesn't make sense, since if the lvalue is constrained to be
of struct type instead, you could possibly access an undefined value
e.g. the float value.

Interpretation B is that

an object of type int can be accessed by a lvalue of type union { int
i; float f; }.i or union {int i; float f; }.f etc.

This hinges on the phrase "through an lvalue", since the actual lvalue
is no longer of union (or struct) type. I see a lot of gcc users
advocating this, e.g. Mark Mitchell of Codesourcery who contributed
the type-based alias analysis code to gcc.

Interpretation C is that

an object of type union { int i; float f; }; or union { union { int i;
float f; } float g; }; can be accessed by a lvalue of type int or
float

This seems the safest, but relies on twisting the order of the
language in the Standard.

So which is it?

Cheers,
Glen Low, Pixelglow Software
www.pixelglow.com


      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



