Error : cannot compile this unexpected cast lvalue yet

Error : cannot compile this unexpected cast lvalue yet

我正在针对 Apple Clang 进行测试,我遇到了一个我过去没有遇到过的错误。代码如下,如果缺少 _mm_set_epi64x 内在函数,它将替换它。

#if defined(__clang__)
#  define GCC_INLINE inline
#  define GCC_INLINE_ATTRIB __attribute__((__gnu_inline__, __always_inline__))
#elif (GCC_VERSION >= 30300) || defined(__INTEL_COMPILER)
#  define GCC_INLINE __inline
#  define GCC_INLINE_ATTRIB __attribute__((__gnu_inline__, __always_inline__, __artificial__))
#else
#  define GCC_INLINE inline
#  define GCC_INLINE_ATTRIB
# endif

...

GCC_INLINE __m128i GCC_INLINE_ATTRIB
MM_SET_EPI64X(const word64 a, const word64 b)
{
    const word64 t[2] = {b,a}; __m128i r;
    asm ("movdqu %1, %0" : "=x"(r) : "m"(t));
    return r;
}

错误是:

c++ -DNDEBUG -g2 -O2 -c sha.cpp
In file included from sha.cpp:24:
./cpu.h:689:39: error: cannot compile this unexpected cast lvalue yet
        asm ("movdqu %1, %0" : "=x"(r) : "m"(t));

Apple Clang 版本为:

$ c++ --version
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

根据 Clang Bug 20201,该问题已得到解决。我的 20201 错误问题是:

  1. 不知道是不是同一个问题
  2. 问题没有解释
  3. 未提供解决方法
  4. Apple 已放弃其软件

由于 (4),我必须尝试修复它。由于(2)和(3),我不知道如何解决它。

这是什么问题,我该如何解决?

好的,随机猜测的时间,但它似乎工作......环顾相关的错误报告,有this posting说:

This was fixed by the work to remove cv-qualifiers from non-class rvalues.

这向我表明,在内部结构中存在一些 const 属性,所以像这样:

word64 a1 = a, b1 = b;
word64 t[2] = {b1,a1};

可能有效,因为通过复制到一个明确声明的非 const 变量,abconstness 的传播被阻止,希望。这已被 OP 确认为有效,因此他们的最终解决方案在这里呈现给后代:

GCC_INLINE __m128i GCC_INLINE_ATTRIB
MM_SET_EPI64X(const word64 a, const word64 b)
{
#if defined(__clang__)
    word64 t1 = a, t2 = b; 
    const word64 t[2] = {t2,t1}; __m128i r;
    asm ("movdqu %1, %0" : "=x"(r) : "m"(t));
    return r;
#else
    const word64 t[2] = {b,a}; __m128i r;
    asm ("movdqu %1, %0" : "=x"(r) : "m"(t));
    return r;
#endif
}