Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

error: class "__m128" has no suitable assignment operator

Matt_S_2
Beginner
450 Views

This code 

#include <xmmintrin.h>

 

volatile __m128 a, b;

 

void test(void)

{

     a = b;

}

 

produces this error

$ /opt/intel/composerxe/bin/icpc -c test.cc

test.cc(7): error: class "__m128" has no suitable assignment operator

       a = b;

           ^

 

compilation aborted for test.cc (code 2)

 

when compiled with icpc.  There is no error if the variables are not volatile.  There is no error with icc or gcc or g++.

Any suggestion on how to compile it with icpc?

 

 

0 Kudos
4 Replies
Shenghong_G_Intel
450 Views

I've reproduced the issue and the issue is caused by wrong processing in C++ mode. ICC is the C compiler and ICPC is the C++ compiler, if you name your file as ".cpp", even icc will fail (as icc will use icpc for .cpp files).

Is there any reason you must use icpc to compile? You may force icpc to build in C mode to avoid the bug...see below:

$ cat temp.c
#include <xmmintrin.h>
#ifndef OK
volatile
#endif
__m128 a, b;
void test(void) { a = b; }
$ gcc temp.c -c
$ g++ temp.c -c
$ g++ -x c++ temp.c -c
$ icc temp.c -c
$ icc -x c++ temp.c -c
temp.c(6): error: class "__m128" has no suitable assignment operator
  void test(void) { a = b; }
                        ^

compilation aborted for temp.c (code 2)
$ icpc temp.c -c
temp.c(6): error: class "__m128" has no suitable assignment operator
  void test(void) { a = b; }
                        ^

compilation aborted for temp.c (code 2)
$ icpc -x c temp.c -c
$ icpc temp.c -c -DOK
$

GNU compiler will build ok in both C and C++ mode, but our compiler will fail in C++ mode. So, the workaround is to use C mode (use .c as file extension with icc, or use -x c for icpc).

Thanks,

Shenghong

0 Kudos
Shenghong_G_Intel
450 Views

FYI. I'll track the issue as DPD200367042 in our problem tracking system.

Thanks,

Shenghong

0 Kudos
Matt_S_2
Beginner
450 Views

Thanks for the update.  Unfortunately, this is a simplified example from a large code base; compiling it in C mode is not an option.

0 Kudos
Shenghong_G_Intel
450 Views

Hi Matt,

FYI. This issue is fixed in v16.0 beta Update 1 version.

$ source /opt/intel/compilers_and_libraries_2016.0.056/linux/bin/compilervars.sh intel64
$ icc -x c++ temp.c -c
$ cat temp.c
#include <xmmintrin.h>
#ifndef OK
volatile
#endif
__m128 a, b;
void test(void) { a = b; }
$

Thanks,

Shenghong

0 Kudos
Reply