From -3333914034063321903
X-Google-Thread: f78e5,1130823ffefc6ebe
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news1.google.com!news1.google.com!newshub.sdsu.edu!news-xfer.cox.net!peer01.cox.net!cox.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: tannhauser86549spam@free.fr (=?ISO-8859-1?Q?Falk_Tannh=E4user?=)
Newsgroups: comp.std.c++
Subject: Re: Unions up in arms!
Date: Tue, 14 Sep 2004 22:59:42 GMT
Organization: Guest of ProXad - France
Lines: 46
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <41476579$0$12975$626a14ce@news.free.fr>
References: <9215d7ac.0409081832.4ab088d6@posting.google.com> <d6652001.0409130421.2c2cccc1@posting.google.com> <84523212.0409140907.46471b77@posting.google.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: news.demon.co.uk 1095202788 20504 158.152.254.254 (14 Sep 2004 22:59:48 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 14 Sep 2004 22:59:48 +0000 (UTC)
X-Received-SPF: none (mailbox2.ucsd.edu: domain of root@news.free.fr does not designate permitted sender hosts)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707
X-Path: comp-std-cpp-robomod!not-for-mail
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i8EMxgkb020653;
	Wed, 15 Sep 2004 08:59:42 +1000 (EST)
X-NNTP-Posting-Date: 14 Sep 2004 23:41:13 MEST
X-Delivered-To: std-c++@ucar.edu
X-Spamscanner: mailbox2.ucsd.edu  (v1.5 Aug 25 2004 09:28:35, 0.2/5.0 3.0.0-rc1)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-MIME-Autoconverted: from 8bit to quoted-printable by mulga.cs.mu.OZ.AU id i8EMxhQs020663
X-Spam-Checker-Version: SpamAssassin 2.64-mulga_r1 (2004-01-11) on 
	mulga.cs.mu.OZ.AU
X-Accept-Language: de, fr, pl, en, en-us
X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=ham 
	version=2.64-mulga_r1
X-Newsgroups: comp.std.c++
X-MailScanner: PASSED (v1.2.8 78657 i8ELfHYl088393 mailbox2.ucsd.edu)
Xref: g2news1.google.com comp.std.c++:2628

Vladimir Marko wrote:

> kanze@gabi-soft.fr wrote in message news:<d6652001.0409130421.2c2cccc1@=
posting.google.com>...
>=20
>>    struct S { int i ; float f ; } ;
>>    float ff ;
>>
>>    S* ps ;
>>    float* pf ;
[...]
>>For the rest, there are a lot of other rules which have to be taken
>>into account.  Thus, for example, *(float*)ps is definitly not
>>a legal access, despite the text you quote.
>=20
> Oh, really? First, we have 9.2/17:
>   A pointer to a POD-struct object, suitably converted using a
>   reinterpret_cast, points to its initial member (or if that member
>   is a bit-field, then to the unit in which it resides) and vice versa.
> Thus, *(int*)ps is surely valid.

OK. It's an lvalue referring to the same object as 'ps->i'.

> Then, 9.5/1 says
>   [snip] Each data member is allocated as if it were the sole member of
>   a struct. [snip]

But 'ps' in the above example is a pointer to struct, and =A7 9.5/1 conce=
rns
unions. If 'S' were a union, I agree that 'reinterpret_cast<float*>(ps)'
would be well defined and equal to '&ps->f'.

> It comes down to the question "How deep is that 'as if'?" Is it deep
> enough for the 9.2/17 to apply?

Well, being "the sole member of a struct" implies being its initial
member, so =A7 9.2/17 indirectly applies to each union member IMO.

Falk Tannh=E4user

---
[ 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                       ]



