Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 836 Bytes

compiler-warning-level-1-c4319.md

File metadata and controls

27 lines (22 loc) · 836 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 1) C4319
Compiler Warning (level 1) C4319
01/18/2018
C4319
C4319
1fac8048-9bd6-4552-a21c-192c67772bb9

Compiler Warning (level 1) C4319

'~' : zero extending 'type1' to 'type2' of greater size

The result of the ~ (bitwise complement) operator is unsigned and then zero-extended when it is converted to a larger type.

Example

In the following example, ~(a - 1) is evaluated as a 32-bit unsigned long expression and then converted to 64 bits by zero extension. This could lead to unexpected operation results.

// C4319.cpp
// compile with: cl /W4 C4319.cpp
int main() {
   unsigned long a = 0;
   unsigned long long q = 42;
   q = q & ~(a - 1);    // C4319 expected
}