Consider the following code:
// Thin/POD struct
struct Data {
__m256d a;
__m256d b;
};
// Thick base class
class Base {
// ...
};
// Thick derived class
class Derived : public Base {
Data data;
// ...
};
Is there a way to ensure that Derived::data
member is properly aligned for AVX (32 byte alignment)?
Because the derived class has a base, there doesn't seem to be a way for something like class alignas(32) Derived
and placing data
as the first member of Derived
.
Derived
is currently allocated on the stack only, but it may need heap allocation later too.
UPDATE: The compiler is MSVC++2017 , so C++11/14/17 is (partially) supported.