Skip to content

Commit 00c57bb

Browse files
author
Ross McAllister
authored
Merge pull request MicrosoftDocs#1822 from corob-msft/cr-warning-ver
Add new compiler warnings for 15.8, 15.9, 16.0
2 parents d45ec3f + 3b8c8e6 commit 00c57bb

4 files changed

Lines changed: 95 additions & 22 deletions

File tree

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
---
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"
44
f1_keywords: ["C4800"]
55
helpviewer_keywords: ["C4800"]
66
ms.assetid: 4f409799-a250-45ed-bb5f-657691b0d9f7
77
---
8-
# Compiler Warning (level 3) C4800
8+
# Compiler Warning (level 4) C4800
99

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:
1016
> '*type*' : forcing value to bool 'true' or 'false' (performance warning)
1117
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
1323

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
1527

1628
## Example
1729

1830
The following sample generates C4800 and shows how to fix it:
1931

2032
```cpp
2133
// C4800.cpp
22-
// compile with: /W3
34+
// compile with: /W4 /w44800
2335
int main() {
2436
int i = 0;
2537

‎docs/error-messages/compiler-warnings/compiler-warnings-by-compiler-version.md‎

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ helpviewer_keywords: ["warnings, by compiler version", "cl.exe compiler, setting
55
---
66
# Compiler Warnings by compiler version
77

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 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.
99

1010
These versions of the compiler introduced new warnings:
1111

@@ -28,18 +28,52 @@ These versions of the compiler introduced new warnings:
2828
| Visual C++ 2017 version 15.6 | 19.13.26128.0 |
2929
| Visual C++ 2017 version 15.7 | 19.14.26428.0 |
3030
| 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 |
3133

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.
3335

3436
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.
3537

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+
3652
## Warnings introduced in Visual C++ 2017 version 15.8 (compiler version 19.15.26726.0)
3753

3854
These warnings and all warnings in later versions are suppressed by using the compiler option __/Wv:19.14__.
3955

4056
|||
4157
|-|-|
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
71+
C5102 | ignoring invalid command-line macro definition '*value*'
72+
C5103 | pasting '*token1*' and '*token2*' does not result in a valid preprocessing token
73+
C5104 | found '*string1*#*string2*' in macro replacement list, did you mean '*string1*""#*string2*'?
74+
C5105 | macro expansion producing 'defined' has undefined behavior
75+
C5106 | macro redefined with different parameter names
76+
C5107 | missing terminating '*char*' character
4377

4478
## Warnings introduced in Visual C++ 2017 version 15.7 (compiler version 19.14.26428.0)
4579

@@ -104,6 +138,8 @@ C4698|'*feature*' is for evaluation purposes only and is subject to change or re
104138
C4839|non-standard use of class '*class*' as an argument to a variadic function
105139
C4840|non-portable use of class '*class*' as an argument to a variadic function
106140

141+
::: moniker-end
142+
107143
## Warnings introduced in Visual C++ 2015 Update 3 (compiler version 19.00.24215.1)
108144

109145
These warnings and all warnings in later versions are suppressed by using the compiler option __/Wv:19.00.23918__.
@@ -375,12 +411,12 @@ C4581|deprecated behavior: '"*name*"' replaced with '*name*' to process attribut
375411
C4606|#pragma warning: '*number*' ignored; Code Analysis warnings are not associated with warning levels
376412
C4631|MSXML or XPath unavailable, XML document comments will not be processed. *description*
377413
C4632|XML document comment: *description* - access denied: *description*
378-
C4633|XML document comment*description*: error: *description*
379-
C4634|XML document comment*description*: cannot be applied: *description*
380-
C4635|XML document comment*description*: badly-formed XML: *description*
381-
C4636|XML document comment*description*: tag requires non-empty '*description*' attribute.
382-
C4637|XML document comment*description*: \<include> tag discarded. *description*
383-
C4638|XML document comment*description*: reference to unknown symbol '*description*'.
414+
C4633|XML document comment *description*: error: *description*
415+
C4634|XML document comment *description*: cannot be applied: *description*
416+
C4635|XML document comment *description*: badly-formed XML: *description*
417+
C4636|XML document comment *description*: tag requires non-empty '*description*' attribute.
418+
C4637|XML document comment *description*: \<include> tag discarded. *description*
419+
C4638|XML document comment *description*: reference to unknown symbol '*description*'.
384420
C4639|MSXML error, XML document comments will not be processed. *description*
385421
C4641|XML document comment has an ambiguous cross reference:
386422
C4678|base class '*declaration*' is less accessible than '*name*'

‎docs/error-messages/compiler-warnings/compiler-warnings-c4800-through-c4999.md‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "Compiler Warnings C4800 Through C5999"
3-
ms.date: "10/24/2018"
4-
f1_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4841", "C4842", "C4843", "C4844", "C4872", "C4880", "C4881", "C4882", "C4910", "C4916", "C4921", "C4934", "C4951", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4985", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5033", "C5034", "C5035", "C5036", "C5037", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5045"]
5-
helpviewer_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4841", "C4842", "C4843", "C4844", "C4872", "C4880", "C4881", "C4882", "C4910", "C4916", "C4921", "C4934", "C4951", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4985", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5033", "C5034", "C5035", "C5036", "C5037", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5045"]
3+
ms.date: "03/14/2019"
4+
f1_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4841", "C4842", "C4843", "C4844", "C4845", "C4846", "C4847", "C4848", "C4872", "C4880", "C4881", "C4882", "C4910", "C4916", "C4921", "C4934", "C4951", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4985", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5033", "C5034", "C5035", "C5036", "C5037", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5045", "C5046", "C5047", "C5048", "C5049", "C5050", "C5100", "C5101", "C5102", "C5103", "C5104", "C5105", "C5106", "C5107"]
5+
helpviewer_keywords: ["C4808", "C4809", "C4825", "C4827", "C4837", "C4841", "C4842", "C4843", "C4844", "C4845", "C4846", "C4847", "C4848", "C4872", "C4880", "C4881", "C4882", "C4910", "C4916", "C4921", "C4934", "C4951", "C4954", "C4955", "C4963", "C4966", "C4970", "C4971", "C4973", "C4974", "C4981", "C4985", "C4987", "C4988", "C4989", "C4990", "C4991", "C4992", "C4998", "C5022", "C5023", "C5024", "C5025", "C5026", "C5027", "C5028", "C5029", "C5030", "C5031", "C5032", "C5033", "C5034", "C5035", "C5036", "C5037", "C5039", "C5040", "C5041", "C5042", "C5043", "C5044", "C5045", "C5046", "C5047", "C5048", "C5049", "C5050", "C5100", "C5101", "C5102", "C5103", "C5104", "C5105", "C5106", "C5107"]
66
---
77
# Compiler Warnings C4800 Through C5999
88

@@ -14,7 +14,7 @@ The articles in this section of the documentation explain a subset of the warnin
1414

1515
|Warning|Message|
1616
|-------------|-------------|
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 |
1818
|[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*'|
1919
|[Compiler Warning (level 1) C4804](compiler-warning-level-1-c4804.md)|'*operation*': unsafe use of type 'bool' in operation|
2020
|[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
4545
|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|
4646
|Compiler warning C4843|'*type1*': An exception handler of reference to array or function type is unreachable, use '*type2*' instead|
4747
|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 |
4852
|[Compiler warning (level 4) C4866](c4866.md)| compiler may not enforce left-to-right evaluation order for call to *operator_name*|
4953
|[Compiler Warning (Error) C4867](compiler-warning-c4867.md)|'*function*': function call missing argument list; use '*call*' to create a pointer to member|
5054
|[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
144148
|Compiler warning (level 4) C5044|An argument to command-line option *option* points to a path '*path*' that does not exist|
145149
|[Compiler warning C5045](c5045.md)|Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified|
146150
|[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 |
157+
| Compiler warning (level 1) C5102 | ignoring invalid command-line macro definition '*value*' |
158+
| Compiler warning (level 1) C5103 | pasting '*token1*' and '*token2*' does not result in a valid preprocessing token |
159+
| Compiler warning (level 1) C5104 | found '*string1*#*string2*' in macro replacement list, did you mean '*string1*""#*string2*'? |
160+
| Compiler warning (level 1) C5105 | macro expansion producing 'defined' has undefined behavior |
161+
| Compiler warning (level 1) C5106 | macro redefined with different parameter names |
162+
| Compiler warning (level 1) C5107 | missing terminating '*char*' character |

0 commit comments

Comments
 (0)