Sign in to follow this  

C++ SSE segfault

This topic is 4110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites

This topic is 4110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this