Re: [eigen] strange sizeof on windows

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Benoit Jacob schrieb:
2009/1/5 FMDSPAM <fmdspam@xxxxxxxxx>:
can you try this:

struct empty {};
struct foo : empty
{
 float x;
};

and print sizeof(foo), sizeof(empty), sizeof(float) ?

Sure,

sizeof(foo) = 4
sizeof(empty) = 1
sizeof(float) = 4

Thanks very much. So at least here, your compiler has performed the
EBCO (empty base class optimization)
http://www.informit.com/articles/article.aspx?p=31473&seqNum=2
(Indeed that turns out to be a nonstandard optimization performed only
by certain compilers).

The question now is, why doesn't it perform the EBCO with Eigen::Matrix ?
Maybe it's related to the multiple inheritance. Can you please try:

struct empty1 {};
struct empty2 {};
struct foo : empty1, empty2
{
 float x;
};

what is sizeof(foo) now ?

Sure,

sizeof(foo) = 8
sizeof(empty1) = 1
sizeof(empty2) = 1
sizeof(float) = 4

Gotcha! :-(


---


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/