编译器警告(等级 1)C4293

“operator”: 移位计数为负或过大,其行为未定义

如果移位计数为负或过大,则生成的图像的行为未定义。

备注

若要解决此问题,可以对第一个操作数使用强制转换以将其扩展到结果类型的大小。

示例

下面的示例生成 C4293,并演示如何修复此错误:

// C4293.cpp
// compile with: /c /W1
unsigned __int64 combine (unsigned lo, unsigned hi)
{
   return (hi << 32) | lo;   // C4293

   // In C, try the following line instead:
   // return ( (unsigned __int64)hi << 32) | lo;
   // In C++, try this line instead:
   // return (static_cast<unsigned __int64>(hi) << 32) | lo;
}