Possible Duplicate:
SSE, intrinsics, and alignment
I'm new to SIMD programming, so please excuse me if I'm asking an obvious question.
I was experimenting a bit and got to a point where I want to store a SIMD value in a dynamically allocated structure.
Here's the code:
struct SimdTest
{
__m128 m_simdVal;
void setZero()
{
__m128 tmp = _mm_setzero_ps();
m_simdVal = tmp; // <<--- CRASH ---
}
};
TEST( Plane, dynamicallyAllocatedPlane )
{
SimdTest* test = new SimdTest();
test->setZero();
delete test;
}
When the method marked with CRASH comment is executed, the code crashes with the following exception:
Unhandled exception at 0x775315de in test-core.exe: 0xC0000005: Access violation reading location 0x00000000
Could someone please explain why does the assignment operation break, and how should SIMD-containing objects be allocated dynamically so that they work fine?
I need to add that if I statically instantiate a SimdTest object and call the setZero method, everything works fine.
Thanks, Paksas