Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

GNU inline assembly: ICC memory input interpretation differs from GCC/Clang

$
0
0

Dear developers,

Please consider the following code snippet.

Compiled with GCC or Clang, it prints "abcdefghijklmno" but with ICC, it prints junk bytes.

The problem here is that when an entry allows only memory constraint, both GCC and Clang interpret the following expression as an lvalue, whereas ICC interpret it as an expression either way.

Thus, here, the token %1 is "expected" to be substituted by the address of the memory block pointed by s but is substituted by an address that point to the value of s here.

This behavior is not really documented, but still, casting a pointer to an array type is suggested in the examples given by GCC here.

So, I am wondering if this difference is made on purpose by ICC or if it could be considered as a bug.

Best regards,

Frédéric Recoules

 

 

#include <stdio.h>

static inline void copy128(void *d, const void *s)
{
  __asm__("movaps   %1, %%xmm0  \n\t""movaps   %%xmm0, %0  \n\t"
          : "=m"(*(char (*)[16])d)
          : "m" (*(const char (*)[16])s)
          : "xmm0");
}

int main (int argc, char *argv[])
{
  const char t[16] = "abcdefghijklmno";
  char u[16];

  copy128(u, t);
  printf("%s\n", u);

  return 0;
}


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>