Skip to content

Commit 07eb3ed

Browse files
author
Colin Robertson
committed
Add missing error messages DD194612
1 parent 16bed43 commit 07eb3ed

7 files changed

+270
-8
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@
293293
## [Compiler Warning (level 1) C4440](compiler-warning-level-1-c4440.md)
294294
## [Compiler Warning (level 1) C4441](compiler-warning-level-1-c4441.md)
295295
## [Compiler Warning (level 1) C4445](compiler-warning-level-1-c4445.md)
296+
## [Compiler warning (level 4) C4456](compiler-warning-level-4-c4456.md)
297+
## [Compiler warning (level 4) C4457](compiler-warning-level-4-c4457.md)
298+
## [Compiler warning (level 4) C4458](compiler-warning-level-4-c4458.md)
299+
## [Compiler Warning (level 4) C4459](compiler-warning-level-4-c4459.md)
296300
## [Compiler Warning (level 4) C4460](compiler-warning-level-4-c4460.md)
297301
## [Compiler Warning (level 1) C4461](compiler-warning-level-1-c4461.md)
298302
## [Compiler Warning (level 1) C4462](compiler-warning-level-1-c4462.md)

docs/error-messages/compiler-warnings/compiler-warning-level-4-c4295.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ translation.priority.ht:
3535
- "zh-tw"
3636
---
3737
# Compiler Warning (level 4) C4295
38-
**'**
39-
***array* ' : array is too small to include a terminating null character**
38+
39+
> '*array*' : array is too small to include a terminating null character
4040
4141
An array was initialized but the last character in the array is not a null; accessing the array may produce unexpected results.
4242

43-
The following sample generates C4295:
43+
## Example
44+
45+
The following sample generates C4295. To fix this issue, you could declare the array size larger, to hold a terminating null from the initializer.
4446

45-
```
47+
```C
4648
// C4295.c
4749
// compile with: /W4
4850

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: "Compiler Warning (level 4) C4456 | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/04/2016"
5+
ms.reviewer: ""
6+
ms.suite: ""
7+
ms.technology:
8+
- "devlang-cpp"
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "error-reference"
11+
f1_keywords:
12+
- "C4456"
13+
dev_langs:
14+
- "C++"
15+
helpviewer_keywords:
16+
- "C4456"
17+
ms.assetid: 5ab39fc1-0e19-461b-842b-4da80560b044
18+
caps.latest.revision: 0
19+
author: "corob-msft"
20+
ms.author: "corob"
21+
manager: "ghogen"
22+
translation.priority.ht:
23+
- "cs-cz"
24+
- "de-de"
25+
- "es-es"
26+
- "fr-fr"
27+
- "it-it"
28+
- "ja-jp"
29+
- "ko-kr"
30+
- "pl-pl"
31+
- "pt-br"
32+
- "ru-ru"
33+
- "tr-tr"
34+
- "zh-cn"
35+
- "zh-tw"
36+
---
37+
# Compiler Warning (level 4) C4456
38+
39+
> declaration of '*identifier*' hides previous local declaration
40+
41+
The declaration of *identifier* in the local scope hides the declaration of the previous local declaration of the same name. This warning lets you know that references to *identifier* in the local scope resolve to the locally declared version, not the previous local, which may or may not be your intent. To fix this issue, we recommend you give local variables names that do not conflict with other local names.
42+
43+
## Example
44+
45+
The following sample generates C4456 because the loop control variable `int x` and the local variable `double x` in `member_fn` have the same names. To fix this issue, use different names for the local variables.
46+
47+
```cpp
48+
// C4456_hide.cpp
49+
// compile with: cl /W4 /c C4456_hide.cpp
50+
51+
struct S {
52+
void member_fn(unsigned u) {
53+
double x = 0;
54+
for (int x = 0; x < 10; ++x) { // C4456
55+
u += x; // uses local int x
56+
}
57+
x += u; // uses local double x
58+
}
59+
} s;
60+
```
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: "Compiler Warning (level 4) C4457 | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/04/2016"
5+
ms.reviewer: ""
6+
ms.suite: ""
7+
ms.technology:
8+
- "devlang-cpp"
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "error-reference"
11+
f1_keywords:
12+
- "C4457"
13+
dev_langs:
14+
- "C++"
15+
helpviewer_keywords:
16+
- "C4457"
17+
ms.assetid: 02fd149a-917d-4f67-97a6-eb714572271f
18+
caps.latest.revision: 0
19+
author: "corob-msft"
20+
ms.author: "corob"
21+
manager: "ghogen"
22+
translation.priority.ht:
23+
- "cs-cz"
24+
- "de-de"
25+
- "es-es"
26+
- "fr-fr"
27+
- "it-it"
28+
- "ja-jp"
29+
- "ko-kr"
30+
- "pl-pl"
31+
- "pt-br"
32+
- "ru-ru"
33+
- "tr-tr"
34+
- "zh-cn"
35+
- "zh-tw"
36+
---
37+
# Compiler Warning (level 4) C4457
38+
39+
> declaration of '*identifier*' hides function parameter
40+
41+
The declaration of *identifier* in the local scope hides the declaration of the identically-named function parameter. This warning lets you know that references to *identifier* in the local scope resolve to the locally declared version, not the parameter, which may or may not be your intent. To fix this issue, we recommend you give local variables names that do not conflict with parameter names.
42+
43+
## Example
44+
45+
The following sample generates C4457 because the parameter `x` and the local variable `x` in `member_fn` have the same names. To fix this issue, use different names for the parameters and local variables.
46+
47+
```cpp
48+
// C4457_hide.cpp
49+
// compile with: cl /W4 /c C4457_hide.cpp
50+
51+
struct S {
52+
void member_fn(unsigned x) {
53+
double a = 0;
54+
for (int x = 0; x < 10; ++x) { // C4457
55+
a += x; // uses local x
56+
}
57+
a += x; // uses parameter x
58+
}
59+
} s;
60+
```
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: "Compiler Warning (level 4) C4458 | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/04/2016"
5+
ms.reviewer: ""
6+
ms.suite: ""
7+
ms.technology:
8+
- "devlang-cpp"
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "error-reference"
11+
f1_keywords:
12+
- "C4458"
13+
dev_langs:
14+
- "C++"
15+
helpviewer_keywords:
16+
- "C4458"
17+
ms.assetid: 7bdaa1b1-0caf-4d68-98c4-6bdd441c23fb
18+
caps.latest.revision: 0
19+
author: "corob-msft"
20+
ms.author: "corob"
21+
manager: "ghogen"
22+
translation.priority.ht:
23+
- "cs-cz"
24+
- "de-de"
25+
- "es-es"
26+
- "fr-fr"
27+
- "it-it"
28+
- "ja-jp"
29+
- "ko-kr"
30+
- "pl-pl"
31+
- "pt-br"
32+
- "ru-ru"
33+
- "tr-tr"
34+
- "zh-cn"
35+
- "zh-tw"
36+
---
37+
# Compiler Warning (level 4) C4458
38+
39+
> declaration of '*identifier*' hides class member
40+
41+
The declaration of *identifier* in the local scope hides the declaration of the identically-named *identifier* at class scope. This warning lets you know that references to *identifier* in this scope resolve to the locally declared version, not the class member version, which may or may not be your intent. To fix this issue, we recommend you give local variables names that do not conflict with class member names.
42+
43+
## Example
44+
45+
The following sample generates C4458 because the parameter `x` and the local variable `y` in `member_fn` have the same names as data members in the class. To fix this issue, use different names for the parameters and local variables.
46+
47+
```cpp
48+
// C4458_hide.cpp
49+
// compile with: cl /W4 /c C4458_hide.cpp
50+
51+
struct S {
52+
int x;
53+
float y;
54+
void member_fn(long x) { // C4458
55+
double y; // C4458
56+
y = x;
57+
// To fix this issue, change the parameter name x
58+
// and local name y to something that does not
59+
// conflict with the data member names.
60+
}
61+
} s;
62+
```
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: "Compiler Warning (level 4) C4459 | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/04/2016"
5+
ms.reviewer: ""
6+
ms.suite: ""
7+
ms.technology:
8+
- "devlang-cpp"
9+
ms.tgt_pltfrm: ""
10+
ms.topic: "error-reference"
11+
f1_keywords:
12+
- "C4459"
13+
dev_langs:
14+
- "C++"
15+
helpviewer_keywords:
16+
- "C4459"
17+
ms.assetid: ee9f6287-9c70-4b10-82a0-add82a13997f
18+
caps.latest.revision: 0
19+
author: "corob-msft"
20+
ms.author: "corob"
21+
manager: "ghogen"
22+
translation.priority.ht:
23+
- "cs-cz"
24+
- "de-de"
25+
- "es-es"
26+
- "fr-fr"
27+
- "it-it"
28+
- "ja-jp"
29+
- "ko-kr"
30+
- "pl-pl"
31+
- "pt-br"
32+
- "ru-ru"
33+
- "tr-tr"
34+
- "zh-cn"
35+
- "zh-tw"
36+
---
37+
# Compiler Warning (level 4) C4459
38+
39+
> declaration of '*identifier*' hides global declaration
40+
41+
The declaration of *identifier* in the local scope hides the declaration of the identically-named *identifier* in global scope. This warning lets you know that references to *identifier* in this scope resolve to the locally declared version, not the global version, which may or may not be your intent. Generally, we recommend you minimize the use of global variables as a good engineering practice. To minimize pollution of the global namespace, we recommend use of a named namespace for global variables.
42+
43+
This warning was new in Visual Studio 2015, in Visual C++ compiler version 18.00. To suppress warnings from that version of the compiler or later while migrating your code, use the [/Wv:18](../../build/reference/compiler-option-warning-level.md) compiler option.
44+
45+
## Example
46+
47+
The following sample generates C4459:
48+
49+
```cpp
50+
// C4459_hide.cpp
51+
// compile with: cl /W4 /EHsc C4459_hide.cpp
52+
int global_or_local = 1;
53+
54+
int main() {
55+
int global_or_local; // warning C4459
56+
global_or_local = 2;
57+
}
58+
```
59+
60+
One way to fix this issue is to create a namespace for your globals, but not use a `using` directive to bring that namespace into scope, so all references must use the unambiguous qualified names:
61+
62+
```cpp
63+
// C4459_namespace.cpp
64+
// compile with: cl /W4 /EHsc C4459_namespace.cpp
65+
namespace globals {
66+
int global_or_local = 1;
67+
}
68+
69+
int main() {
70+
int global_or_local; // OK
71+
global_or_local = 2;
72+
globals::global_or_local = 3;
73+
}
74+
```

docs/error-messages/compiler-warnings/compiler-warnings-c4400-through-c4599.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ You may find additional assistance for errors and warnings on the MSDN public fo
208208
|Compiler warning (level 1) C4453|'*type*': A '[WebHostHidden]' type should not be used on the published surface of a public type that is not '[WebHostHidden]'|
209209
|Compiler warning (level 1) C4454|'*function*' is overloaded by more than the number of input parameters without having [DefaultOverload] specified. Picking '*declaration*' as the default overload|
210210
|Compiler warning (level 1) C4455|'operator *operator*': literal suffix identifiers that do not start with an underscore are reserved|
211-
|Compiler warning (level 3) C4456|declaration of '*identifier*' hides previous local declaration|
212-
|Compiler warning (level 3) C4457|declaration of '*identifier*' hides function parameter|
213-
|Compiler warning (level 3) C4458|declaration of '*identifier*' hides class member|
214-
|Compiler warning (level 3) C4459|declaration of '*identifier*' hides global declaration|
211+
|[Compiler warning (level 4) C4456](compiler-warning-level-4-c4456.md)|declaration of '*identifier*' hides previous local declaration|
212+
|[Compiler warning (level 4) C4457](compiler-warning-level-4-c4457.md)|declaration of '*identifier*' hides function parameter|
213+
|[Compiler warning (level 4) C4458](compiler-warning-level-4-c4458.md)|declaration of '*identifier*' hides class member|
214+
|[Compiler warning (level 4) C4459](compiler-warning-level-4-c4459.md)|declaration of '*identifier*' hides global declaration|
215215
|[Compiler Warning (level 4) C4460](../../error-messages/compiler-warnings/compiler-warning-level-4-c4460.md)|'WinRT&#124;managed' operator '*operator*', has parameter passed by reference. 'WinRT&#124;managed' operator '*operator*' has different semantics from C++ operator '*cpp_operator*', did you intend to pass by value?|
216216
|[Compiler Warning (level 1) C4461](../../error-messages/compiler-warnings/compiler-warning-level-1-c4461.md)|'*classname*': this class has a finalizer '!*finalizer*' but no destructor '~*dtor*'|
217217
|[Compiler Warning (level 1) C4462](../../error-messages/compiler-warnings/compiler-warning-level-1-c4462.md)|'*type*' : cannot determine the GUID of the type. Program may fail at runtime.|

0 commit comments

Comments
 (0)