作者:手机用户2502906377 | 来源:互联网 | 2023-05-19 18:03
Idontunderstandwhythecommentedanduncommentedlinedontyieldthesameresult(LinuxGCC,wi
I don't understand why the commented and uncommented line don't yield the same result (Linux GCC, with C++11 flag enabled):
我不理解为什么注释和未注释的行不会产生相同的结果(Linux GCC,启用了c++ 11标志):
#include "immintrin.h"
typedef __m256 floatv;
struct floatv2{
public:
//floatv2(const float f):x(_mm256_setzero_ps() + f ), y(_mm256_setzero_ps() + f ) {}; // succeeds
floatv2(const float f):x{_mm256_setzero_ps() + f }, y{_mm256_setzero_ps() + f } {}; // fails
//private:
floatv x, y;
};
When trying to compile the uncommented line I get the following error:
当试图编译未注释的行时,我得到以下错误:
error: cannot convert ‘__m256 {aka __vector(8) float}’ to ‘float’ in initialization
which I don't understand because x
and y
are floatv, not float, so no conversion should be required...
我不明白,因为x和y是floatv,而不是float,所以不需要转换。
Also, in some more complex code, the first version produces memory access violation. Is there something nasty going on behind the scene?
另外,在一些更复杂的代码中,第一个版本会产生内存访问冲突。幕后发生了什么令人不快的事情吗?
PS: above the definition of __m256, in avxintrin.h, there is the following comment:
在avxintrin中,在__m256的定义之上。h,有以下评论:
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
I don't understand what this means, but feel like it could be related :)
我不明白这是什么意思,但感觉可能是相关的:
Many thanks
非常感谢
2 个解决方案