From 1004917304780935388
X-Google-Thread: f78e5,1130823ffefc6ebe,start
X-Google-Thread: fc772,1130823ffefc6ebe,start
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!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: Unions up in arms!
Date: Fri, 10 Sep 2004 15:13:17 +0000 (UTC)
Organization: http://groups.google.com
Lines: 61
Sender: cppmods@netlab.cs.rpi.edu
Approved: stephen.clamage@sun.com (comp.std.c++)
Message-ID: <9215d7ac.0409081832.4ab088d6@posting.google.com>
NNTP-Posting-Host: taumet.sfbay.sun.com
X-Trace: news1nwk.SFbay.Sun.COM 1094829197 81 129.146.79.208 (10 Sep 2004 15:13:17 GMT)
X-Complaints-To: usenet@news1nwk.sfbay.sun.com
NNTP-Posting-Date: Fri, 10 Sep 2004 15:13:17 +0000 (UTC)
X-Original-NNTP-posting-date: Fri, 10 Sep 2004 14:02:36 +0000 (UTC)
Delivered-to: std-c++@ucar.edu
Received-SPF: none (mailbox10.ucsd.edu: domain of news@rpi.edu does not
 designate permitted sender hosts)
X-Original-Date: Wed, 08 Sep 2004 19:32:39 -0700
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
 iQBVAwUAQUG0wkHMCo9UcraBAQHHjAH+JMWu8sI6zV+o5oqRDlks5V9th9DWg5za
  h7TKo5sNbGWu49m+5murNs4XYxgeZsD7HQ2ippVmNjVDpZasZrw0gQ==                =+P3n
X-Approved-For-Group: francis.moderator@robinton.demon.co.uk
 comp.lang.c++.moderated
X-NNTP-posting-host: netlab.cs.rpi.edu
Original-recipient: rfc822;stephen.clamage@sun.com
Originator: clamage@taumet
Xref: g2news1.google.com comp.std.c++:2523 comp.lang.c++.moderated:7937


Color me stupid, but after months of staring I still can't grok this
clause in the Standard 3.10/15:

----

If a program attempts to access the stored value of an object through
an lvalue of other than one of the following types the behavior is
undefined:

an aggregate or union type that includes one of the aforementioned
types among its members (including, recursively, a member of a
subaggregate or contained union),

----

Suppose

int j;
union u { int i; float f; };

Then which of the following is illegal, if any, and why? (Putting
aside, if possible, the legality of the popular type-punning practice
of putting x into a union and getting back y.)

A.

j = 12;
int k = ((u&) j).i;

B.

j = 12;
u v = (u&) j;

C.

u v = {12};
float g = v.f;

D.

j = 12;
float g = ((u&) j).f;

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

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                       ]



