|
Boost : |
From: Bohdan (gejrlaug_at_[hidden])
Date: 2003-09-25 19:16:23
"Rozental, Gennadiy" <gennadiy.rozental_at_[hidden]> wrote in message
news:1373D6342FA1D4119A5100E029437F6405E1FA72_at_clifford.devo.ilx.com...
> > "Rozental, Gennadiy" <gennadiy.rozental_at_[hidden]> wrote in
> > message
> > news:1373D6342FA1D4119A5100E029437F6405E1FA69_at_clifford.devo.ilx.com...
> > > Probably not. Because of the alignment.
> > >
> > > struct A {
> > > int a;
> > > char b;
> > > };
> > >
> > > sizeof(A) = 8
> > >
> > > Gennadiy
> > >
> >
> > I'm using bcc32 option -a1 -Vx -Ve which means that
> > 1. -a1 : aligment is 1
>
> This basically says - disregard alignment
>
> > 2. -Vx : Zero-length class data member
> > 3. -Ve : Zero-length empty base classes
> >
> > And with this option set your example gives size 5,
> > and sizeof(variant<int>) is still is 8.
>
> This is probably because Eric is using int as a type for selector member.
As i can see there is some code which decides whether to use char or short
as selector, unfortunately something is wrong. Is such size overhead actual for
borland only or other compilers are doing the same ?
BTW, using more than 256 types in variant is crazy :o)
> I
> mentioned it to him during review that it should be char. On the other hand
> I found that In majority of the cases (when you are not or could not ignore
> alignment) size will be the same.
If this san help somehow here is a table for bolrand 5.5.1:
-a1 -Vx -Ve size: 8
-a1 -Ve size: 8
-a1 -Vx size: 8
-a1 size: 9
-a2 -Vx -Ve size: 8
-a2 -Vx size: 8
-a2 -Ve size: 8
-a2 size: 10
-a4 -Vx -Ve size: 8
-a4 -Vx size: 8
-a4 -Ve size: 8
-a4 size: 12
-a8 -Vx -Ve size: 16
-a8 -Vx size: 16
-a8 -Ve size: 16
-a8 size: 24
regards,
bohdan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk