I'm working with a library which has aligned types, and I have a structure that contains an array of one of these types. My compiler (MSVC) is complaining with the error message in the title (citing my structure when I try to dynamically allocate it).
Here's the class in question, from Embree (Raytracing software):
# define RTCORE_ALIGN(...) __declspec(align(__VA_ARGS__))
#ifndef __RTCRay8__
#define __RTCRay8__
struct RTCORE_ALIGN(32) RTCRay8
{
//data
}
My struct looks like this:
struct ContainerThing
{
RTCRay8 ray_packets[SIZE_CONSTANT];
}
Would I be correct in saying that because the RTCRay8 array is inside of a dynamically allocated class, the alignment guarantees are lost? The array will therefore be potentially misaligned?
If that's what's happening, my question is: What is the solution? It seems like I will need to derive from RTCRay8 to fix this, but will overriding new and delete for that derived type work, or will I simply need to manually align the class (add padding to the end)?