SSE and C++ containers

前端 未结 4 1237
情书的邮戳
情书的邮戳 2020-12-09 20:26

Is there an obvious reason why the following code segfaults ?

#include 
#include 

struct point {
    __m128i v;

  point()          


        
4条回答
  •  Happy的楠姐
    2020-12-09 20:47

    SSE intrinsics are required to be 16-byte aligned in memory. When you allocate an __m128 on the stack, there's no problem because the compiler automatically aligns these correctly. The default allocator for std::vector<>, which handles dynamic memory allocation, does not produce aligned allocations.

提交回复
热议问题