From -4796312076548492459
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!cyclone1.gnilink.net!gnilink.net!peer01.cox.net!cox.net!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: Wed, 15 Sep 2004 14:34:18 +0000 (UTC)
Organization: http://groups.google.com
Lines: 42
Sender: cppmods@netlab.cs.rpi.edu
Approved: stephen.clamage@sun.com (comp.std.c++)
Message-ID: <9215d7ac.0409140039.727afd2f@posting.google.com>
References: <9215d7ac.0409081832.4ab088d6@posting.google.com>
 <d6652001.0409130421.2c2cccc1@posting.google.com>
NNTP-Posting-Host: taumet.sfbay.sun.com
Content-Type: TEXT/PLAIN
X-Trace: news1nwk.SFbay.Sun.COM 1095258858 1478 129.146.79.208 (15 Sep 2004 14:34:18 GMT)
X-Complaints-To: usenet@news1nwk.sfbay.sun.com
NNTP-Posting-Date: Wed, 15 Sep 2004 14:34:18 +0000 (UTC)
X-Original-NNTP-posting-date: Wed, 15 Sep 2004 00:49:09 +0000 (UTC)
Delivered-to: std-c++@ucar.edu
X-Original-Date: Tue, 14 Sep 2004 01:39:33 -0700
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
 iQBVAwUAQUeSPEHMCo9UcraBAQE64AIAo+mD4bKD28AKH855MD5rS68bP+Pw9gqY
 FLY+3SF/o7IYMDf+WU93wIsK6L9TaqiRIic7/YAI5sfWnxltx3Vc3g==                =8V5Y
X-Approved-For-Group: kuehl@inf.uni-konstanz.de 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++:2636 comp.lang.c++.moderated:8247


> The wording is a bit difficult, to put it mildly.  I think that the k
> ey
> is in the (non-normative) footnote.  These restrictions are basicly
> there to tell compiler writers what they can exclude (or rather what
> they cannot exclude) as possible aliases.  Thus, if I have
> 
>     strut S { int i ; float f ; } ;
>     float ff ;
> 
>     S* ps ;
>     float* pf ;
> 
> The compiler must assume that *pf is also accessible via ps.

Hewing close to the language of the Standard, if I store into *pf, the
compiler must assume that a read from *ps would be affected. The
question is, are the following reads also affected: ps->i, ps->f ?
Note that *ps has an lvalue of union type and so the above analysis is
correct, but how about ps->f which has an lvalue of float type? Does
"through an lvalue" mean "an lvalue expression of this exact type" or
"an lvalue expression that contains this type in it e.g. as part of a
member access"?

For the sake of argument, let's assume that sizeof (int) == sizeof
(float) and the data in question is a valid sequence of bits for
either int or float.

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                       ]



