Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 1.15 KB

c26454.md

File metadata and controls

44 lines (34 loc) · 1.15 KB
description title ms.date f1_keywords helpviewer_keywords
Learn more about: Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time
Warning C26454
01/08/2017
C26454
RESULT_OF_ARITHMETIC_OPERATION_NEGATIVE_UNSIGNED
C26454

Warning C26454

Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time

Remarks

This warning indicates that the subtraction operation produces a negative result that was evaluated in an unsigned context, which can result in unintended overflows.

Code analysis name: RESULT_OF_ARITHMETIC_OPERATION_NEGATIVE_UNSIGNED

Example

unsigned int negativeunsigned()
{
    const unsigned int x = 1u - 2u; // C26454 reported here
    return x;
}

To correct this warning, use the following code:

unsigned int negativeunsigned()
{
    const unsigned int x = 4294967295; // OK
    return x;
}

See also

26450
26451
26452
26453
ES.106: Don't try to avoid negative values by using unsigned