vector of __mm128 won't push_back()

☆樱花仙子☆ 提交于 2019-12-21 09:01:42

问题


This simple SSE code:

#include <vector>
#include <emmintrin.h>

int main() {
    std::vector<__m128> blah;
    blah.push_back(__m128());
}

Crashes on MSVC 10 with a segfault at 0xffffffff.

What could be going wrong ?


回答1:


A std::vector does not allocate specially aligned memory, which __m128 needs to store it's data. You will have to either swap out the allocator, or replace it with an array of 4 floats and then perform an unaligned load or copy out to an aligned location every time you access the vector.



来源:https://stackoverflow.com/questions/11679741/vector-of-mm128-wont-push-back

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!