Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 935 Bytes

File metadata and controls

35 lines (28 loc) · 935 Bytes
title C26452
keywords C26452
ms.date 01/08/2017
ms.topic reference
f1_keywords
C26452
helpviewer_keywords
C26452
dev_langs
C++

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