| title |
C26452 |
| description |
Describes causes of MSVC Code analysis warning C26452, and how to fix the issue. |
| ms.date |
07/15/2020 |
| ms.topic |
reference |
| f1_keywords |
|
| helpviewer_keywords |
|
| dev_langs |
|
Arithmetic overflow: Left shift count is negative or greater than or equal to the operand size, which is undefined behavior
This warning indicates the shift count is negative, or greater than or equal to the number of bits in the shifted operand. Either case results in undefined behavior.
C4293 is a similar check in the Microsoft C++ compiler.
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 (static_cast<unsigned __int64>(hi) << 32) | lo; // OK
}
ES.102: Use signed types for arithmetic