错误 : 尚无法编译此意外的强制转换值
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));
苹果叮当版本是:
$ 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 错误的问题是:
- 我不知道是不是同一个问题
- 问题没有解释
- 未提供解决方法
- 苹果已经放弃了其软件
由于(4(,我必须尝试修复它。由于(2(和(3(,我不知道如何解决它。
问题是什么,我该如何解决?
好吧,随机猜测时间,但它似乎有效...环顾相关的错误报告,有这样一篇文章说:
这是通过从非类右值中删除 cv 限定符的工作修复的。
这向我表明,内部结构中还残留着一些const
属性,所以像这样:
word64 a1 = a, b1 = b;
word64 t[2] = {b1,a1};
可能起作用,因为通过复制到显式声明的非const
变量中,可以防止a
和b
的const
传播,希望如此。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
}
相关文章:
- 尝试将字符串/字符转换为整数会产生意外结果
- 使用 sprintf 和 %g 将双精度转换为字符串的意外结果
- 字符数组到十六进制字符串的转换 - 意外输出
- 意外 (IMO) 常量转换警告
- 无效* 转换获得意外输出
- 错误 : 尚无法编译此意外的强制转换值
- 意外行为将字符串转换为const char*
- 将uint64_t转换为双精度后出现意外结果
- 带有布尔转换的变量的原始打印:意外行为
- 将time_t打印为长int而不进行强制转换会产生意外行为
- wchar_t和c_str字符串转换出现意外结果
- 将dword强制转换为字节[4]时出现意外结果(endianity swap?)
- gtest意外转换
- pow()在使用类型转换时会产生意外结果
- 在常规初始化中发生意外转换
- 将十进制数转换为二进制时出现意外结果
- 在递归函数中,c++基转换过程中意外输出到屏幕
- 强制转换时的意外行为
- 意外的大端转换输出
- c++从const int*到int*的转换,处理意外结果