[cfe-dev] clang, C++ and compound literals in SSE2 intrinsics

Jonathan Sauer jonathan.sauer at gmx.de
Sat Apr 23 03:05:01 PDT 2011


Hello,

compiling some SSE2 code with clang in C++0x mode and "-pedantic", I got the following warning:
"Compound literals are a C99-specific feature". I looked into the file "emmintrin.h" coming with
clang, where the warning originated, and _mm_shuffle_epi32 (as well as some other intrinsics)
indeed uses compound literals (emphasis mine):

#define _mm_shuffle_epi32(a, imm) \
  ((__m128i)__builtin_shufflevector((__v4si)(a), (__v4si) {0}, \
                                                 ^^^^^^^^^^^^
                                    (imm) & 0x3, ((imm) & 0xc) >> 2, \
                                    ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6))


The code works correctly, so clang is able to compile it. Still, I'd like to get rid of the false
warning. IMO there are two possibilities:

1. Change emmintrin.h so that the intrinsics are implemented without compound literals (if
   possible)

2. Change emmintrin.h so that the compound literal warning is suppressed just for that file.

Unfortunately, I don't know to perform either change. I'm not even sure if (2) is currently
possible with clang at all.

What do you think?


Jonathan





More information about the cfe-dev mailing list