C++ SSE segfault
Hello,
I'm trying to write simple 3d vector class using SSE. Everything works fine when using static objects but anytime I try using dynamic allocation it crashes with segfault. I suppose it's problem with memory alignment but I can't figure out what is wrong.
This code crashes at v.m = _mm_set1_ps(0.0f);
#ifdef __SSE__
#include <xmmintrin.h>
#else
#error NO SSE
#endif
union sse4{
__m128 m;
struct{ float x,y,z,w; };
float f[4];
};
class vector3d{
sse4 v;
public:
vector3d(){ v.m = _mm_set1_ps(0.0f); }
};
int main(){
vector3d *test[100];
for(unsigned int t = 0; t < 100; t++){
test[t] = new vector3d;
}
return 0;
}
g++ -ggdb -msse -mfpmath=sse code.cpp -o code
Does anybody have a solution?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement