我遇到了一个奇怪的情况,alignof(__m512)它不等于std::alignment_of<__m512>::value由 Apple 的 clang 编译。经过一些测试,我发现当alignof(T)在模板中使用 进行评估时T=__m512,结果与直接不同alignof(__m512)。我还在 ubuntu(WSL) 上运行了几个由 g++ 和非 Apple 的 clang 编译的测试,并得到了正确的(我认为)行为。这是Apple的clang错误还是有关实施行为的问题?
#include <immintrin.h> //avx headers
#include <cstdio>
#include <typeinfo>
#include <type_traits>
void test_directly() {
printf("directly: typeid %s alignof %zu\n", typeid(__m512).name(), alignof(__m512));
}
template<typename T>
void test_as_template_argument() {
static_assert(std::is_same<T, __m512>::value, "assert");
printf("template: typeid %s alignof %zu\n", typeid(T).name(), alignof(T));
}
int main() {
test_directly();
test_as_template_argument<__m512>();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出(编译clang++ -std=c++17 -march=native):
directly: typeid Dv16_f alignof 64
template: typeid Dv16_f alignof 32
Run Code Online (Sandbox Code Playgroud)
叮当的版本:
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Run Code Online (Sandbox Code Playgroud)
macOS 的版本: macOS Catalina 10.15.4 (19E2269) Darwin 19.4.0
| 归档时间: |
|
| 查看次数: |
457 次 |
| 最近记录: |