From: Marco (mrcekets_at_[hidden])
Date: 2007-10-02 10:26:06
First off thanks a lot for the detailed explanation and reference.
On Tue, 02 Oct 2007 15:01:36 +0200, Sebastian Redl
> Marco wrote:
>> Are you speaking about rules provided in the C++ ISO standard ? Could
>> point me to them ? (page, section). I'd like to give them a look .
> 9.2/16 is where it gets interesting. It says that, if two structs in a
> union share a common initial subsequence of layout-compatible types, you
> can access the fields of this sequence through either struct name.
So what you are saying it's that definition 9.2/14 about layout compatible
structs has not provided to suggest that code like Marco Servetto's code
is valid, but only in order to state the 9.2/16 rule.
> Layout compatibility is not mentioned anywhere else. So what does that
> It means that, by the words of the standard, your code was not valid. On
> the other hand, making both structs the members of a union, then
> assigning one and reading the other, is valid. Make of that what you
> Sebastian Redl
Maybe there is a little misunderstanding because I'm another Marco, but
that doesn't matter :-)
What I'm interesting is if the standard says something about declaration
order of struct fields and their storage order in memory. But it appears
that such relation is definitively implementation dependent, except for
what stated at paragraph 9.2/17 as you pointed out.
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk