Boost logo

Boost :

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
<sebastian.redl_at_[hidden]> wrote:

> Marco wrote:
>> Are you speaking about rules provided in the C++ ISO standard ? Could
>> you
>> 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
> mean?
> 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
> will.
> 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.

Kind Regards,
Marco Cecchetti

Using Opera's revolutionary e-mail client:

Boost list run by bdawes at, gregod at, cpdaniel at, john at