当我尝试使用icpc进行编译时,它显示“表达式必须具有类类型”。对此感到困惑。请帮忙。
int main()
{
__m256d temp;
temp.m256d_f64[0] = 1;
return 0;
}
最佳答案
我可以重现此问题。在英特尔编译器随附的immintrin.h中,我们对__m256d具有以下定义:
typedef struct _MMINTRIN_TYPE(32) __m256d {
double m256d_f64[4];
} __m256d;
在上面的定义中,结构名称和别名相同,这使当前的编译器感到困惑。 Intel Compiler似乎没有将typedef名称识别为可以用较小的测试用例证明的类:
$ cat test1.cc
typedef struct __m256d {
double m256d_f64[4];
} m256d;
int main()
{
__m256d temp;
temp.m256d_f64[0] = 1;
return 0;
}
$ icpc test1.cc –c
当我如下所示更改typedef和实例化temp(使用typedefed名称而不是struct名称)时,ICC会失败,但GCC会起作用:
$ cat test1.cc
typedef struct m256d {
double m256d_f64[4];
} __m256d;
int main()
{
__m256d temp;
temp.m256d_f64[0] = 1;
return 0;
}
$ icpc test1.cc -c
test1.cc(8): error: expression must have class type
temp.m256d_f64[0] = 1;
^
compilation aborted for test1.cc (code 2)
$ g++ test1.cc -c
我已将此问题报告给英特尔的编译器工程团队。