Is there an obvious reason why the following code segfaults ?
#include
#include
struct point {
__m128i v;
point()
The vector
constructor you are using is actually defined like this:
explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );
(see e.g., http://www.cplusplus.com/reference/stl/vector/vector/).
In other words, one element is default constructed (i.e., the default parameter value as you call the constructor), and the remaining elements are then created by copying the first one. My guess is that you need a copy constructor for point
that properly handles the (non-)copying of __m128i
values.
Update: When I try to build your code with Visual Studio 2010 (v. 10.0.30319.1), I get the following build error:
error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned c:\program files\microsoft visual studio 10.0\vc\include\vector 870 1 meh
This suggests Ben is right on the money regarding this being an alignment problem.