Re: [eigen] Alignment of a derived class |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Alignment of a derived class
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 18 Jul 2012 23:29:29 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=cpyL5vHysril68SukfbxdTrqsGH8jAs8wX0i3uQnVRE=; b=0gM2WTLaNRy9dhQh1zfmP7zIvHzyoc0Lxf7JDZS9C/AoGQD2xTD7+phjs9cB9ojwzT enq6oOTlkf81C8VLYKzDwdzFhs5j6TEMsDhFer5RFsLQ3kviVvkSLr8UzJgpJAL8/SZO arsXYy2xIr/Nox7VcMBw1ookxbySK52vR+HtfWzQJYhVKLAeUI9ln6LU/QlCnapRcE9d JoTDD5B8c9FBgUYG9ue+806TAwpPAzMCCvwWMw/7kIR6H8Rtx4b8neGQbjAlKxrQR8iE bPIiK3uXbrjhaKK6PbXxXKeAelBt1eHe4f3pkX/B/E8r18NuuN8bps9DS2kVI9U+U6Iw aknw==
Hi Martin,
On Wed, Jul 18, 2012 at 4:18 AM, Martin Sälzle <martin.saelzle@xxxxxxx> wrote:
> Hi,
>
> Please consider this example:
>
> struct Base
> {
> Eigen::Vector4f vec4f_base;
> EIGEN_MAKE_ALIGNED_OPERATOR_NEW
> };
>
> struct Derived1 : public Base
> {
> Eigen::Vector4f vec4f_derived_1;
> EIGEN_MAKE_ALIGNED_OPERATOR_NEW
> };
>
> struct Derived2 : public Base
> {
> Eigen::Vector4f vec4f_derived_2;
> };
>
> I would like to know if Derived1 and / or Derived 2 are aligned, given that Base is aligned.
yes for both.
> The next question is if EIGEN_MAKE_ALIGNED_OPERATOR_NEW is needed in the derived class (Derived1 vs Derived2).
No, having it in Base is enough.
> The final question is what would happen for Derived1 if Base does note have EIGEN_MAKE_ALIGNED_OPERATOR_NEW?
On a 64bits system nothing special. On a 32bits system with SSE
enabled, an abort or segfault if you create a Derived1 on the heap
using "new Derived1".
gael
> thank you and best regards,
> Martin
>