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
{{ message }}
Repository navigation
Commit b0cb612
Browse filesBrowse the repository at this point in the historyBrowse files
Colin Robertson
authored
Merge pull request MicrosoftDocs#857 from MicrosoftDocs/master636885276184293672
Copy file name to clipboardExpand all lines: docs/error-messages/compiler-warnings/compiler-warning-level-3-c4800.md
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,37 @@
1
1
---
2
-
title: "Compiler Warning (level 3) C4800"
3
-
ms.date: "11/04/2016"
2
+
title: "Compiler Warning (level 4) C4800"
3
+
ms.date: "03/14/2019"
4
4
f1_keywords: ["C4800"]
5
5
helpviewer_keywords: ["C4800"]
6
6
ms.assetid: 4f409799-a250-45ed-bb5f-657691b0d9f7
7
7
---
8
-
# Compiler Warning (level 3) C4800
8
+
# Compiler Warning (level 4) C4800
9
9
10
+
::: moniker range=">= vs-2019"
11
+
Visual Studio 2019 and later:
12
+
> Implicit conversion from '*type*' to bool. Possible information loss
13
+
::: moniker-end
14
+
15
+
C4800 is a level 3 warning in Visual Studio 2015 and earlier:
10
16
> '*type*' : forcing value to bool 'true' or 'false' (performance warning)
11
17
12
-
This warning is generated when a value that is not `bool` is assigned or coerced into type `bool`. Typically, this message is caused by assigning `int` variables to `bool` variables where the `int` variable contains only values **true** and **false**, and could be redeclared as type `bool`. If you cannot rewrite the expression to use type `bool`, then you can add "`!=0`" to the expression, which gives the expression type `bool`. Casting the expression to type `bool` does not disable the warning, which is by design.
18
+
This warning is generated when a value is implicitly converted into type `bool`. Typically, this message is caused by assigning `int` variables to `bool` variables where the `int` variable contains only values **true** and **false**, and could be redeclared as type `bool`. If you can't rewrite the expression to use type `bool`, then you can add "`!=0`" to the expression, which gives the expression type `bool`. Casting the expression to type `bool` doesn't disable the warning, which is by design.
19
+
20
+
::: moniker range=">= vs-2017"
21
+
This warning is not emitted in Visual Studio 2017.
22
+
::: moniker-end
13
23
14
-
This warning is no longer generated in Visual Studio 2017.
24
+
::: moniker range=">= vs-2019"
25
+
This warning is off by default starting in Visual Studio 2019. Use __/w__*n*__4800__ to enable C4800 as a level *n* warning, or [/Wall](../../build/reference/compiler-option-warning-level.md) to enable all warnings that are off by default. For more information, see [Compiler Warnings That Are Off By Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md).
26
+
::: moniker-end
15
27
16
28
## Example
17
29
18
30
The following sample generates C4800 and shows how to fix it:
The compiler can suppress warnings that were introduced after a version you specify by using the [/Wv](../../build/reference/compiler-option-warning-level.md) compiler option. This is useful for managing your build process when you introduce a new toolset version, and want to temporarily suppress new warnings. This option does not suppress new error messages. We do not recommend you suppress all new warnings permanently! We recommend you always compile at the highest regular warning level, __/W4__, and remove the __/Wv__ option in your build as soon as possible.
8
+
The compiler can suppress warnings that were introduced after a version you specify by using the [/Wv](../../build/reference/compiler-option-warning-level.md) compiler option. This option is useful for managing your build process when you introduce a new toolset version, and want to temporarily suppress new warnings. This option does not suppress new error messages. We do not recommend you suppress all new warnings permanently! We recommend you always compile at the highest regular warning level, __/W4__, and remove the __/Wv__ option in your build as soon as possible.
9
9
10
10
These versions of the compiler introduced new warnings:
11
11
@@ -28,18 +28,52 @@ These versions of the compiler introduced new warnings:
28
28
| Visual C++ 2017 version 15.6 | 19.13.26128.0 |
29
29
| Visual C++ 2017 version 15.7 | 19.14.26428.0 |
30
30
| Visual C++ 2017 version 15.8 | 19.15.26726.0 |
31
+
| Visual C++ 2017 version 15.9 | 19.16.26926.0 |
32
+
| Visual C++ 2019 RTM | 19.20.27004.0 |
31
33
32
-
You can specify only the major number, the major and minor numbers, or the major, minor, and build numbers to the __/Wv__ option. The compiler reports all warnings which match versions that begin with the specified number, and suppresses all warnings for versions greater than the specified number. For example, __/Wv:17__ reports all warnings introduced in or before any version of Visual Studio 2012, and suppresses all warnings introduced by any compiler from Visual Studio 2013 (version 18) or later. To suppress warnings introduced in Visual Studio 2015 update 2 and later, you can use __/Wv:19.00.23506__. Use __/Wv:19.11__ to report all warnings introduced in any version of Visual Studio before Visual Studio 2017 version 15.5, but suppresses warnings introduced in Visual Studio 2017 version 15.5 and later.
34
+
You can specify only the major number, the major and minor numbers, or the major, minor, and build numbers to the __/Wv__ option. The compiler reports all warnings that match versions that begin with the specified number, and suppresses all warnings for versions greater than the specified number. For example, __/Wv:17__ reports all warnings introduced in or before any version of Visual Studio 2012, and suppresses all warnings introduced by any compiler from Visual Studio 2013 (version 18) or later. To suppress warnings introduced in Visual Studio 2015 update 2 and later, you can use __/Wv:19.00.23506__. Use __/Wv:19.11__ to report all warnings introduced in any version of Visual Studio before Visual Studio 2017 version 15.5, but suppresses warnings introduced in Visual Studio 2017 version 15.5 and later.
33
35
34
36
The following sections list the warnings introduced by each version of Visual C++ that you can suppress by using the __/Wv__ compiler option. The __/Wv__ option can't suppress warnings that are not listed, which predate the specified versions of the compiler.
35
37
38
+
::: moniker range=">= vs-2019"
39
+
40
+
## Warnings introduced in Visual C++ 2019 RC (compiler version 19.20.27004.0)
41
+
42
+
These warnings and all warnings in later versions are suppressed by using the compiler option __/Wv:19.15__.
43
+
44
+
|||
45
+
|-|-|
46
+
C4848 | support for standard attribute 'no\_unique\_address' in C++17 and earlier is a vendor extension
47
+
48
+
::: moniker-end
49
+
::: moniker range=">= vs-2017"
50
+
51
+
36
52
## Warnings introduced in Visual C++ 2017 version 15.8 (compiler version 19.15.26726.0)
37
53
38
54
These warnings and all warnings in later versions are suppressed by using the compiler option __/Wv:19.14__.
39
55
40
56
|||
41
57
|-|-|
42
-
C5046|'*function*' : Symbol involving type with internal linkage not defined|
58
+
C4643 | Forward declaring '*identifier*' in namespace std is not permitted by the C++ Standard.
59
+
C4644 | usage of the macro-based offsetof pattern in constant expressions is non-standard; use offsetof defined in the C++ standard library instead
60
+
C4845 | '\_\_declspec(no\_init\_all)' is ignored if '/d1initall\[0\|1\|2\|3]' was not specified on the command line
61
+
C4846 | '*value*' is not a valid argument for '/d1initall': command-line flag ignored
62
+
C4847 | '\_\_declspec(no\_init\_all)' can only be applied to a function, a class type, or a local variable: ignored
63
+
C4866 | compiler may not enforce left-to-right evaluation order for call to '*function*'
64
+
C5046 | '*function*': Symbol involving type with internal linkage not defined
65
+
C5047 | use of nonstandard \_\_if\_exists with modules is not supported
66
+
C5048 | Use of macro '*macroname*' may result in non-deterministic output
67
+
C5049 | '*string*': Embedding a full path may result in machine-dependent output
68
+
C5050 | Possible incompatible environment while importing module '*module_name*': *issue*
69
+
C5100 | \_\_VA\_ARGS\_\_ is reserved for use in variadic macros
70
+
C5101 | use of preprocessor directive in function-like macro argument list is undefined behavior
@@ -14,7 +14,7 @@ The articles in this section of the documentation explain a subset of the warnin
14
14
15
15
|Warning|Message|
16
16
|-------------|-------------|
17
-
|[Compiler Warning (level 3) C4800](compiler-warning-level-3-c4800.md)|'*type*': forcing value to bool 'true' or 'false' (performance warning)|
17
+
|[Compiler Warning (level 4) C4800](compiler-warning-level-3-c4800.md)| Implicit conversion from '*type*'to bool. Possible information loss |
18
18
|[Compiler Warning (level 1) C4803](compiler-warning-level-1-c4803.md)|'*method*': the raise method has a different storage class from that of the event, '*event*'|
19
19
|[Compiler Warning (level 1) C4804](compiler-warning-level-1-c4804.md)|'*operation*': unsafe use of type 'bool' in operation|
20
20
|[Compiler Warning (level 1) C4805](compiler-warning-level-1-c4805.md)|'*operation*': unsafe mix of type '*type1*' and type '*type2*' in operation|
@@ -45,6 +45,10 @@ The articles in this section of the documentation explain a subset of the warnin
45
45
|Compiler warning (level 4) C4842|the result of 'offsetof' applied to a type using multiple inheritance is not guaranteed to be consistent between compiler releases|
46
46
|Compiler warning C4843|'*type1*': An exception handler of reference to array or function type is unreachable, use '*type2*' instead|
47
47
|Compiler warning C4844|'export module *module_name*;' is now the preferred syntax for declaring a module interface|
48
+
| Compiler warning (level 4) C4845 | '\_\_declspec(no\_init\_all)' is ignored if '/d1initall\[0\|1\|2\|3]' was not specified on the command line |
49
+
| Compiler warning (level 4) C4846 | '*value*' is not a valid argument for '/d1initall': command-line flag ignored |
50
+
| Compiler warning (level 4) C4847 | '\_\_declspec(no\_init\_all)' can only be applied to a function, a class type, or a local variable: ignored |
51
+
| Compiler warning (level 1) C4848 | support for standard attribute 'no\_unique\_address' in C++17 and earlier is a vendor extension |
48
52
|[Compiler warning (level 4) C4866](c4866.md)| compiler may not enforce left-to-right evaluation order for call to *operator_name*|
49
53
|[Compiler Warning (Error) C4867](compiler-warning-c4867.md)|'*function*': function call missing argument list; use '*call*' to create a pointer to member|
50
54
|[Compiler Warning (level 4) C4868](compiler-warning-c4868.md)|'_file_(*line_number*)' compiler may not enforce left-to-right evaluation order in braced initialization list|
@@ -144,3 +148,15 @@ The articles in this section of the documentation explain a subset of the warnin
144
148
|Compiler warning (level 4) C5044|An argument to command-line option *option* points to a path '*path*' that does not exist|
145
149
|[Compiler warning C5045](c5045.md)|Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified|
146
150
|[Compiler warning (level 2) C5046](c5046.md)|'*function*' : Symbol involving type with internal linkage not defined|
151
+
| Compiler warning (level 1) C5047 | use of nonstandard \_\_if\_exists with modules is not supported |
152
+
| Compiler warning (level 1) C5048 | Use of macro '*macroname*' may result in non-deterministic output |
153
+
| Compiler warning (level 1) C5049 | '*string*': Embedding a full path may result in machine-dependent output |
154
+
| Compiler warning (level 1) C5050 | Possible incompatible environment while importing module '*module_name*': *issue*|
155
+
| Compiler warning (level 1) C5100 |\_\_VA\_ARGS\_\_ is reserved for use in variadic macros |
156
+
| Compiler warning (level 1) C5101 | use of preprocessor directive in function-like macro argument list is undefined behavior |
0 commit comments