You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/error-messages/compiler-warnings/compiler-warning-levels-3-and-4-c4244.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
2
description: "Learn more about: Compiler Warning (levels 3 and 4) C4244"
3
3
title: "Compiler Warning (levels 3 and 4) C4244"
4
-
ms.date: "11/04/2016"
4
+
ms.date: "11/6/2023"
5
5
---
6
6
# Compiler Warning (levels 3 and 4) C4244
7
7
8
8
'conversion' conversion from 'type1' to 'type2', possible loss of data
9
9
10
10
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.
13
13
14
14
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.
15
15
@@ -27,7 +27,7 @@ int main() {
27
27
unsigned int uint1 = 2;
28
28
29
29
short short1 = int1; // C4244
30
-
short short2 = (short)int1; // OK
30
+
short short2 = (short)int1; // warning silenced - explicit cast
31
31
32
32
short short3 = uint1; // C4244
33
33
unsigned short ushort = uint1; // C4244
@@ -36,7 +36,7 @@ int main() {
36
36
```
37
37
38
38
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)
0 commit comments