Differences in struct size when compiling C vs. C++
Andrea 'Fyre Wyzard' Bocci
fwyzard@inwind.it
Tue Jan 22 13:09:00 GMT 2002
I'm not sure how it REALLY works.
From what I understood, the problem should arise when coding the class like
>template<class T>
>struct A
>{
> T c;
> int a;
> int b;
>};
because the member class would otherwise (ie, without the extra byte) have
the same address as the container struct.
On the other hand, if you write, like in your example,
>template<class T>
>struct A
>{
> int a;
> int b;
> T c;
>};
the extrra space should not be needed, as A and A.c already have differetn
addresses.
If the proble shows up even in this second example, then there must
something else causing it.
In this case, you might try posting again to gcc-help@gcc.gnu.org and
gcc@gcc.gnu.org (this might be a feature, a bug, or whatever...).
HTH
fwyzard
More information about the Gcc-help
mailing list