Skip to content

Commit 5ea57af

Browse files
authored
Merge pull request #5734 from Rageking8/structure-warning-references-in-range-c4831-c4940
Structure warning references in range [C4831, C4940]
2 parents 10fbfeb + 9d1b13d commit 5ea57af

32 files changed

+190
-139
lines changed

docs/error-messages/compiler-warnings/c4834.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To turn off the warning for an entire project in the Visual Studio IDE:
3030

3131
## Example
3232

33-
This sample generates C4834, and shows four ways to fix it:
33+
This example generates C4834, and shows four ways to fix it:
3434

3535
```cpp
3636
// C4834.cpp

docs/error-messages/compiler-warnings/c4841.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 4) C4841"
32
title: "Compiler Warning (level 4) C4841"
3+
description: "Learn more about: Compiler Warning (level 4) C4841"
44
ms.date: 05/03/2021
55
f1_keywords: ["C4841"]
66
helpviewer_keywords: ["C4841"]

docs/error-messages/compiler-warnings/c4843.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 4) C4843"
32
title: "Compiler Warning (level 4) C4843"
3+
description: "Learn more about: Compiler Warning (level 4) C4843"
44
ms.date: 05/03/2021
55
f1_keywords: ["C4843"]
66
helpviewer_keywords: ["C4843"]
@@ -17,7 +17,7 @@ This warning is new in Visual Studio 2017 version 15.5. For information on how t
1717

1818
## Example
1919

20-
This sample shows several **`catch`** statements that cause C4843:
20+
This example shows several **`catch`** statements that cause C4843:
2121

2222
```cpp
2323
// C4843_warning.cpp

docs/error-messages/compiler-warnings/c4866.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 4) C4866"
32
title: "Compiler Warning (Level 4) C4866"
4-
ms.date: "09/30/2018"
3+
description: "Learn more about: Compiler Warning (level 4) C4866"
4+
ms.date: 09/30/2018
55
f1_keywords: ["C4866"]
66
helpviewer_keywords: ["C4866"]
77
---
@@ -25,11 +25,11 @@ This warning was introduced in Visual Studio 2017 version 15.9 as a result of co
2525

2626
To resolve this warning, first consider whether left-to-right evaluation of the operator elements is necessary, such as when evaluation of the elements might produce order-dependent side-effects. In many cases, the order in which elements are evaluated does not have an observable effect.
2727

28-
If the order of evaluation must be left-to-right, consider whether you can pass the elements by **`const`** reference instead. This change eliminates the warning in the following code sample.
28+
If the order of evaluation must be left-to-right, consider whether you can pass the elements by **`const`** reference instead. This change eliminates the warning in the following code example.
2929

3030
## Example
3131

32-
This sample generates C4866, and shows a way to fix it:
32+
This example generates C4866, and shows a way to fix it:
3333

3434
```cpp
3535
// C4866.cpp

docs/error-messages/compiler-warnings/compiler-warning-c4867.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
2-
description: "Learn more about: Compiler Warning C4867"
32
title: "Compiler Warning C4867"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning C4867"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4867"]
66
helpviewer_keywords: ["C4867"]
7-
ms.assetid: 8a257d70-c3a7-462d-b285-e57c952a8bf7
87
---
98
# Compiler Warning C4867
109

11-
'function': function call missing argument list; use 'call' to create a pointer to member
10+
> 'function': function call missing argument list; use 'call' to create a pointer to member
11+
12+
## Remarks
1213

1314
A pointer to member function was initialized incorrectly.
1415

@@ -18,7 +19,7 @@ This warning is always issued as an error. Use the [warning](../../preprocessor/
1819

1920
## Example
2021

21-
The following sample generates C4867.
22+
The following example generates C4867.
2223

2324
```cpp
2425
// C4867.cpp

docs/error-messages/compiler-warnings/compiler-warning-c4868.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 4) C4868"
32
title: "Compiler Warning C4868"
4-
ms.date: "10/26/2017"
3+
description: "Learn more about: Compiler Warning (level 4) C4868"
4+
ms.date: 10/26/2017
55
f1_keywords: ["C4868"]
66
helpviewer_keywords: ["C4868"]
7-
ms.assetid: fc6aa7e5-34dd-4ec2-88bd-16e430361dc7
87
---
98
# Compiler Warning (level 4) C4868
109

1110
> '_file_(*line_number*)' compiler may not enforce left-to-right evaluation order in braced initializer list
1211
12+
## Remarks
13+
1314
The elements of a braced initializer list are to be evaluated in left-to-right order. There are two cases in which the compiler is unable to guarantee this order: the first is when some of the elements are objects passed by value; the second is when compiling with `/clr` and some of the elements are fields of objects or are array elements. When the compiler can't guarantee left-to-right evaluation it emits warning C4868.
1415

1516
This warning can be generated as a result of compiler conformance work that was done for Visual Studio 2015 Update 2. Code that compiled prior to Visual Studio 2015 Update 2 can now generate C4868.
@@ -18,11 +19,11 @@ This warning is off by default. Use `/Wall` to activate this warning.
1819

1920
To resolve this warning, first consider whether left-to-right evaluation of the initializer list elements is necessary, such as when evaluation of the elements might produce order-dependent side-effects. In many cases, the order in which elements are evaluated does not have an observable effect.
2021

21-
If the order of evaluation must be left-to-right, consider if it's possible to pass the elements by **`const`** reference instead. A change such as this eliminates the warning in the following code sample.
22+
If the order of evaluation must be left-to-right, consider if it's possible to pass the elements by **`const`** reference instead. A change such as this eliminates the warning in the following code example.
2223

2324
## Example
2425

25-
This sample generates C4868, and shows a way to fix it:
26+
This example generates C4868, and shows a way to fix it:
2627

2728
```cpp
2829
// C4868.cpp

docs/error-messages/compiler-warnings/compiler-warning-c4936.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
2-
description: "Learn more about: Compiler Warning C4936"
32
title: "Compiler Warning C4936"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning C4936"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4936"]
66
helpviewer_keywords: ["C4936"]
7-
ms.assetid: 6676de35-bf1b-4d0b-a70f-b5734130336c
87
---
98
# Compiler Warning C4936
109

@@ -22,7 +21,7 @@ C4936 is always issued as an error. You can disable C4936 with the [warning](..
2221

2322
## Example
2423

25-
The following sample generates C4936:
24+
The following example generates C4936:
2625

2726
```cpp
2827
// C4936.cpp

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4835.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4835"
32
title: "Compiler Warning (level 1) C4835"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4835"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4835"]
66
helpviewer_keywords: ["C4835"]
7-
ms.assetid: d2e44c62-7b0e-4a45-943d-97903e27ed9d
87
---
98
# Compiler Warning (level 1) C4835
109

11-
'variable' : the initializer for exported data will not be run until managed code is first executed in the host assembly
10+
> 'variable' : the initializer for exported data will not be run until managed code is first executed in the host assembly
11+
12+
## Remarks
1213

1314
When accessing data between managed components, it is recommended that you not use native C++ import and export mechanisms. Instead, declare your data members inside a managed type and reference the metadata with `#using` in the client. For more information, see [#using Directive](../../preprocessor/hash-using-directive-cpp.md).
1415

1516
## Examples
1617

17-
The following sample generates C4835.
18+
The following example generates C4835.
1819

1920
```cpp
2021
// C4835.cpp
@@ -26,7 +27,7 @@ __declspec(dllexport) int m = f(); // C4835
2627
__declspec(dllexport) int *p = &n; // C4835
2728
```
2829
29-
The following sample consumes the component built in the previous sample, showing that the value of the variables is not as expected.
30+
The following example consumes the component built in the previous example, showing that the value of the variables is not as expected.
3031
3132
```cpp
3233
// C4835_b.cpp

docs/error-messages/compiler-warnings/compiler-warning-level-1-c4838.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4838"
32
title: "Compiler Warning (level 1) C4838"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4838"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4838"]
66
helpviewer_keywords: ["C4838"]
7-
ms.assetid: fea07924-5feb-4ed4-99b5-1a8c41d28db6
87
---
98
# Compiler Warning (level 1) C4838
109

11-
conversion from 'type_1' to 'type_2' requires a narrowing conversion
10+
> conversion from 'type_1' to 'type_2' requires a narrowing conversion
11+
12+
## Remarks
1213

1314
An implicit narrowing conversion was found when using aggregate or list initialization.
1415

1516
The C language allows implicit narrowing conversions in assignments and initialization, and C++ follows suit, even though unexpected narrowing is a cause of many code errors. To make code safer, the C++ standard requires a diagnostic message when a narrowing conversion occurs in an initialization list. In Visual C++, the diagnostic is [Compiler Error C2397](../../error-messages/compiler-errors-1/compiler-error-c2397.md) when using the uniform initialization syntax supported beginning in Visual Studio 2015. The compiler generates warning C4838 when using the list or aggregate initialization syntax supported by Visual Studio 2013.
1617

1718
A narrowing conversion can be okay when you know the possible range of converted values can fit in the target. In this case, you know more than the compiler does. If you make a narrowing conversion intentionally, make your intentions explicit by using a static cast. Otherwise, this warning message almost always indicates that you have a bug in your code. You can fix it by making sure the objects you initialize have types that are large enough to handle the inputs.
1819

19-
The following sample generates C4838 and shows one way to fix it:
20+
## Example
21+
22+
The following example generates C4838 and shows one way to fix it:
2023

2124
```cpp
2225
// C4838.cpp -- C++ narrowing conversion diagnostics
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
2-
description: "Learn more about: Compiler Warning (level 1) C4900"
32
title: "Compiler Warning (level 1) C4900"
4-
ms.date: "11/04/2016"
3+
description: "Learn more about: Compiler Warning (level 1) C4900"
4+
ms.date: 11/04/2016
55
f1_keywords: ["C4900"]
66
helpviewer_keywords: ["C4900"]
7-
ms.assetid: 826997ec-0803-4794-ad35-bb463f679658
87
---
98
# Compiler Warning (level 1) C4900
109

11-
intermediate language mismatch between 'tool1' version 'version1' and 'tool2' version 'version2'
10+
> intermediate language mismatch between 'tool1' version 'version1' and 'tool2' version 'version2'
11+
12+
## Remarks
1213

1314
The intermediate language used in *tool1* and *tool2* did not match. Check that the most current version of each tool has been installed.

0 commit comments

Comments
 (0)