Skip to content

Commit b4682e2

Browse files
author
Jill Grant
authored
Merge pull request #5486 from Rastaban/docs-editor/compiler-warning-level-3-c4334-1709840074
Update compiler-warning-level-3-c4334.md
2 parents adf6bfb + e9fa361 commit b4682e2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/error-messages/compiler-warnings/compiler-warning-level-3-c4334.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ ms.assetid: d845857f-bc95-4faf-a079-626a0cf935ba
88
---
99
# Compiler Warning (level 3) C4334
1010

11-
'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
11+
'operator': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
1212

13-
The result of 32-bit shift was implicitly converted to 64-bits, and the compiler suspects that a 64-bit shift was intended. To resolve this warning, either use 64-bit shift, or explicitly cast the shift result to 64-bit.
13+
The result of 32-bit shift was converted to 64-bit, and the compiler suspects that a 64-bit shift was intended. Resolve this warning by using a 64-bit shift. If a 32-bit shift is intentional, then cast the shift result to 32-bit to make it clear to the compiler.
1414

1515
## Example
1616

@@ -20,7 +20,9 @@ The following sample generates C4334.
2020
// C4334.cpp
2121
// compile with: /W3 /c
2222
void SetBit(unsigned __int64 *p, int i) {
23-
*p |= (1 << i); // C4334
24-
*p |= (1i64 << i); // OK
23+
*p |= (1 << i); // C4334, 32-bit shift cast to 64-bit
24+
*p |= (1i64 << i); // OK, 64-bit shift
25+
*p |= static_cast<int>(1 << i); // OK, 32-bit shift saved to 64-bit result
26+
*p |= static_cast<__int64>(1) << i; // OK, 64-bit shift
2527
}
2628
```

0 commit comments

Comments
 (0)