9

这个简单的 SSE 代码:

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

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

在 MSVC 10 上崩溃,在0xffffffff.

可能出了什么问题?

4

1 回答 1

13

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.

于 2012-07-27T00:25:50.643 回答