Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2005-08-11 08:00:20


----- Original Message -----
From: "felipe" <pbr_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, August 11, 2005 4:09 AM
Subject: Re: [boost] alignment problem in proposed any alternative

> Nope, this is totally wrong! chars and arrays of type char are generally
> the least aligned objects. You can demonstrate that this doesn't work
> with something like this:
>
> void blah()
> {
> char c[/* some number */];
> any<8> a((double)1.0);
> std::cout << &a << std::endl;
> }

That code is completely misleading, yhe question is not what the address of
a is!

> I think you are misreading 3.9.2: it is talking about pointers, namely
> that void * and char * have the same storage and alignment requirements.

3.9(2) says:
For any complete POD object type T, whether or not the object holds a valid
value of type T, the underlying
bytes (1.7) making up the object can be copied into an array of char or
unsigned char.36) If the content of the array of char or unsigned char is
copied back into the object, the object shall subsequently hold its original
value.

This has nothing to do with void* and char*, but rather with all POD's.

This clearly implies char arrays are stringently aligned.

--
Christopher Diggins
http://www.cdiggins.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk