Error: Cannot use vector unsigned long long[2] to

2019-09-10 12:13发布

问题:

We are testing under Sun Studio 12.3. We are catching a compiler error that's not present under 12.4 and later. Its not present under 12.1 and earlier, but that's because the compiler has trouble with AES instructions. Its also not present under other compilers, like Clang, GCC, ICPC and VC++. The error is:

/opt/solarisstudio12.3/bin/CC -DDEBUG -g3 -xO0 -D__SSE2__ -D__SSE3__ -D__SSSE3__ \
-D__SSE4_1__ -D__SSE4_2__ -D__AES__ -D__PCLMUL__ -D__RDRND__ -D__RDSEED__ -D__AVX__ \
-D__AVX2__ -D__BMI__ -D__BMI2__  -native -m64 -KPIC -template=no%extdef -c rijndael.cpp

"/opt/solarisstudio12.3/prod/include/CC/Cstd/algorithm", line 283: Error: Cannot use vector unsigned long long[2] to initialize vector unsigned long long[2].
"rijndael.cpp", line 277:     Where: While instantiating "std::swap<vector unsigned long long[2]>(unsigned long long(&)[2], unsigned long long(&)[2])".
"rijndael.cpp", line 277:     Where: Instantiated from non-template code.
1 Error(s) detected.
gmake: *** [rijndael.o] Error 2
gmake: *** Waiting for unfinished jobs....
ERROR: failed to make cryptest.exe

The code in question is:

std::swap(*(__m128i*)(rk), *(__m128i*)(rk+4*m_rounds));

I have a couple of questions:

  • What is the compiler having trouble with?
  • What is the best way to clear the error?

I have to ask the second question because I'm not sure of SunCC and the __m128i type given I could use raw memcpy, try to write my own swap, or even try an iter_swap without the dereference.