Skip to content

Commit cc18e22

Browse files
committed
Learn Editor: Update compiler-warning-level-3-c4334.md
1 parent abfd9fc commit cc18e22

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.assetid: d845857f-bc95-4faf-a079-626a0cf935ba
1010

1111
'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-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 32-bit to make the intention clear.
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)