Skip to content

Commit c0fab1c

Browse files
authored
Update compiler-warning-levels-3-and-4-c4244.md
finish edits
1 parent bf1f928 commit c0fab1c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/error-messages/compiler-warnings/compiler-warning-levels-3-and-4-c4244.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
description: "Learn more about: Compiler Warning (levels 3 and 4) C4244"
33
title: "Compiler Warning (levels 3 and 4) C4244"
4-
ms.date: "11/04/2016"
4+
ms.date: "11/6/2023"
55
---
66
# Compiler Warning (levels 3 and 4) C4244
77

88
'conversion' conversion from 'type1' to 'type2', possible loss of data
99

1010
An integer type is converted to a smaller integer type.
11-
- This is a level-4 warning if *type1* is a signed or unsigned **`int`** and *type2* is a smaller--such as a signed or unsigned **`short`**.
12-
- It is a level 3 warning if a value of type [__int64](../../cpp/int8-int16-int32-int64.md) or **`unsigned __int64`** is assigned to a signed or unsigned **`int`**. A possible loss of data may have occurred due to a narrowing conversion, which might lead to unexpected results.
11+
- This is a level-4 warning if *type1* is a signed or unsigned **`int`** and *type2* is a smaller, such as a signed or unsigned **`short`**.
12+
- It is a level 3 warning if a value of type [`__int64`](../../cpp/int8-int16-int32-int64.md) or **`unsigned __int64`** is assigned to a signed or unsigned **`int`**. A possible loss of data may have occurred due to a narrowing conversion, which might lead to unexpected results.
1313

1414
To fix this warning, either change your program to use compatible types, or add logic that ensures that the range of possible values is compatible with the types you are using. If the conversion is intended, use an explicit cast to silence the warning.
1515

@@ -27,7 +27,7 @@ int main() {
2727
unsigned int uint1 = 2;
2828

2929
short short1 = int1; // C4244
30-
short short2 = (short)int1; // OK
30+
short short2 = (short)int1; // warning silenced - explicit cast
3131

3232
short short3 = uint1; // C4244
3333
unsigned short ushort = uint1; // C4244
@@ -36,7 +36,7 @@ int main() {
3636
```
3737
3838
For more information, see [Usual Arithmetic Conversions](../../c-language/usual-arithmetic-conversions.md).\
39-
For more information about setting the warning level in Visual Studio, see[](../build/reference/compiler-option-warnings-level#to-set-the-compiler-options-in-the-visual-studio-development-environment.md)
39+
For more information about setting the warning level in Visual Studio, see[To set the compiler options in the Visual Studio development environment](../build/reference/compiler-option-warnings-level#to-set-the-compiler-options-in-the-visual-studio-development-environment.md)
4040
4141
```cpp
4242
// C4244_level3.cpp

0 commit comments

Comments
 (0)