C++ SSE segfault

Started by
1 comment, last by qrcze 17 years, 7 months ago
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?
Advertisement
Older thread about this.
SSE - Alignment of __m128 Type - how?
Thanks a LOT! That is what i've been looking for.

This topic is closed to new replies.

Advertisement