Arithmetic overflow: Left shift count is negative or greater than or equal to the operand size which is undefined behavior

This warning indicates shift count is negative or greater than or equal to the number of bits of the operand being shifted, resulting in undefined behavior. Note: C4293 is a similar check in the Microsoft C++ compiler.

Example

unsigned __int64 combine(unsigned lo, unsigned hi)
{
  return (hi << 32) | lo; // C26252 here
}

To correct this warning, use the following code:

unsigned __int64 combine(unsigned lo, unsigned hi)
{
  return ((unsigned __int64)hi << 32) | lo; // OK
}

See Also

ES.102: Use signed types for arithmetic