------- Comment #4 from thiago at kde dot org 2010-05-05 19:39 -------
(In reply to comment #3)
> The struct Foo looks like an odd way to try and express
>
> union Foo
> {
> int i;
> char c[sizeof (int)];
> };
Well, that is the objective, but you can't replace int with a non-POD type in
C++98. C++0x relaxes the unions and that's exactly what is intended: delayed
construction.
I used int as an example, but the objective is to have:
template <typename T>
struct Buffer
{
char __attribute__((aligned(__alignof__(T)))) buf[sizeof(T)];
};
[the WebKit WTF::Vector code is a bit more complex than that to get around the
fact that gcc 4.2 can't do aligned(__alignof__(T)), so it partially specialises
alignments of 1, 2, 4, 8, 16, and 64]
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43976