分享方式:


編譯器警告 (層級 1) C4293

' operator ': shift count negative or too big, undefined behavior

如果班次計數是負數或太大,則產生的影像行為是未定義的。

備註

若要解決此問題,您可以使用第一個運算元上的轉換,將其擴充為結果類型的大小。

範例

下列範例會產生 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;
}