|[eigen] Eigen2, G++ and sizeof()|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] Eigen2, G++ and sizeof()
- From: Andri Möll <aoeuid@xxxxxxxxx>
- Date: Sat, 26 Jan 2008 22:17:21 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:x-enigmail-version:content-type:content-transfer-encoding; bh=Sqs/49bhD14nStRsFr4ASDTUCJ+GF9U+DWttTdV9ZUQ=; b=u5GNP0EIkiu8pxjfvmqQ0mo55BKBYNefYu90aIH6RlPDhhT35UjcbC7twgdwTQm5ClXStGvxW/K64FqyP8iW6fKYMk9I80WXOldOJyLVbLICg+q+pm3NX1yfJzZz8fX6Yhrvrlu/4bEmvha77PE6dbzbz6njebJFnnKPr0eUgWs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:x-enigmail-version:content-type:content-transfer-encoding; b=oTA7NX+DJy5xwoqorLiRRoGINAoIxYCK5+H1yWN9sBtMM+Ch24Dc5LUYP1XRRQOxwg298fLHFiz+nYUF5oQKFNJuY0LzwE79pdNr3swb94gsv2GyImVmNHzo2C2JVk7j0SFqAQSYNIAIkRc35ODx+roTujvAjxhY9Z08Tw36MOI=
I was just reviewing Eigen2 and discovered that for some reason GCC's g++ lists
Eigen's matrices a bit larger than they were meant to be.
That is, 16 bytes for Vector3f unpacked, and 14 bytes when packed with #pragma
std::cerr << "sizeof(v) = " << sizeof(v) << std::endl;
std::cerr << "v.size() = " << v.size() << std::endl;
$ g++ -Wall test.cpp && ./a.out
sizeof(eigen) = 16
eigen.size() = 3
My disassembling skills under Unix-like OSes are a bit lacking, but a simple
'info gcc' and removal of some code helped identify the cause, which seems to be
the templated value holding class you're using. GCC's manual says that empty
classes end up with a "virtual" char, so that explains why temporarily removing
dynamic matrix support and substituting it with enums makes the data usage
I'm using Gentoo's stable GCC (4.1.2) and rev 766861 of Eigen2.
I haven't tried the 4.2.x branch of GCC, does that have the same behavior?