Skip to content

Commit 2fc27e3

Browse files
authored
Merge pull request #5888 from TylerMSFT/warningfix
various UUF fixes
2 parents ae38522 + 97cba3e commit 2fc27e3

File tree

6 files changed

+39
-64
lines changed

6 files changed

+39
-64
lines changed

docs/build/adding-references-in-visual-cpp-projects.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ To consume a library that you have downloaded by using the **vcpkg** package man
2121

2222
If your static library project gets built in the same solution:
2323

24-
1. #include the header file(s) for the static library using quotation marks. In a typical solution, the path starts with `../<library project name>`. IntelliSense will help you find it.
24+
1. `#include` the header file(s) for the static library using quotation marks. In a typical solution, the path starts with `../<library project name>`. IntelliSense will help you find it.
2525
2. Add a reference to the static library project. Right-click on **References** under the application project node in **Solution Explorer** and choose **Add Reference**.
2626

2727
If the static library isn't part of the solution:
2828

2929
1. Right-click on the application project node in **Solution Explorer** and then choose **Properties**.
30-
2. In the **VC++ Directories** property page, add the path to the directory that contains the LIB file to **Library Paths**. Then, add the path to the library header file(s) to **Include Directories**.
30+
2. In the **VC++ Directories** property page, add the path to the directory that contains the LIB file to **Library Directories**. Then, add the path to the library header file(s) to **Include Directories**.
3131
3. In the **Linker > Input** property page, add the name of the LIB file to **Additional Dependencies**.
3232

3333
## Dynamic link libraries
@@ -161,5 +161,5 @@ The following properties exist on COM and .NET assembly references, and aren't m
161161

162162
## See also
163163

164-
[C++ project property page reference](reference/property-pages-visual-cpp.md)<br>
164+
[C++ project property page reference](reference/property-pages-visual-cpp.md)\
165165
[Set C++ compiler and build properties in Visual Studio](working-with-project-properties.md)

docs/c-runtime-library/crt-debug-heap-details.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,11 @@ typedef struct _CrtMemBlockHeader
102102

103103
The `no_mans_land` buffers on either side of the user data area of the block are currently 4 bytes in size, and are filled with a known byte value used by the debug heap routines to verify that the limits of the user's memory block haven't been overwritten. The debug heap also fills new memory blocks with a known value. If you elect to keep freed blocks in the heap's linked list, these freed blocks are also filled with a known value. Currently, the actual byte values used are as follows:
104104

105-
`no_mans_land` (0xFD)\
106-
The "no_mans_land" buffers on either side of the memory used by an application are currently filled with 0xFD.
107-
108-
Freed blocks (0xDD)\
109-
The freed blocks kept unused in the debug heap's linked list when the `_CRTDBG_DELAY_FREE_MEM_DF` flag is set are currently filled with 0xDD.
110-
111-
New objects (0xCD)\
112-
New objects are filled with 0xCD when they're allocated.
105+
|Code |Description |
106+
|---------|---------|
107+
|`no_mans_land` (0xFD) | The "no_mans_land" buffers on either side of the memory used by an application are currently filled with 0xFD. |
108+
|Freed blocks (0xDD) | The freed blocks kept unused in the debug heap's linked list when the `_CRTDBG_DELAY_FREE_MEM_DF` flag is set are currently filled with 0xDD. |
109+
|New objects (0xCD) | New objects are filled with 0xCD when they're allocated.|
113110

114111
## Types of blocks on the debug heap
115112

@@ -170,7 +167,7 @@ All calls to heap functions such as `malloc`, `free`, `calloc`, `realloc`, `new`
170167
171168
### To use the debug heap
172169
173-
- Link the debug build of your application with a debug version of the C runtime library.
170+
Link the debug build of your application with a debug version of the C runtime library.
174171
175172
### To change one or more `_crtDbgFlag` bit fields and create a new state for the flag
176173
@@ -275,9 +272,9 @@ Knowing the source file name and line number of an assert or reporting macro is
275272

276273
### Unique allocation request numbers and `_crtBreakAlloc`
277274

278-
There's a simple way to identify the specific heap allocation call that went bad. It takes advantage of the unique allocation request number associated with each block in the debug heap. When information about a block is reported by one of the dump functions, this allocation request number is enclosed in braces (for example, "{36}").
275+
There's a simple way to identify the specific heap allocation call that went bad. It takes advantage of the unique allocation request number associated with each block in the debug heap. When information about a block is reported by one of the dump functions, this allocation request number is enclosed in braces. For example, `{36}`.
279276

280-
Once you know the allocation request number of an improperly allocated block, you can pass this number to [`_CrtSetBreakAlloc`](./reference/crtsetbreakalloc.md) to create a breakpoint. Execution will break just before allocating the block, and you can backtrack to determine what routine was responsible for the bad call. To avoid recompiling, you can accomplish the same thing in the debugger by setting `_crtBreakAlloc` to the allocation request number you're interested in.
277+
Once you know the allocation request number of an improperly allocated block, you can pass this number to [`_CrtSetBreakAlloc`](./reference/crtsetbreakalloc.md) to create a breakpoint. Execution will break just before allocating the block and you can backtrack to determine what routine was responsible for the bad call. To avoid recompiling, you can accomplish the same thing in the debugger by setting `_crtBreakAlloc` to the allocation request number you're interested in.
281278

282279
### Creating debug versions of your allocation routines
283280

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
description: "Learn more about: Compiler Warning (level 1, error) C4430"
33
title: "Compiler warning (level 1, error) C4430"
4-
ms.date: "1/25/2025"
4+
ms.date: 04/22/2025
55
f1_keywords: ["C4430"]
66
helpviewer_keywords: ["C4430"]
77
---
88
# Compiler Warning (level 1, Error) C4430
99

1010
> missing type specifier - int assumed. Note: C++ does not support default-int
1111
12-
This error might be generated due to compiler conformance work done for Visual Studio 2005: all declarations must explicitly specify the type; `int` is no longer assumed.
12+
This warning is issued when a type specifier is missing in a declaration. The compiler used to assume the type was `int` in this case. But due to compiler conformance work done for Visual Studio 2005, all declarations must explicitly specify the type.
1313

1414
C4430 is always issued as an error. You can turn off this warning with the `#pragma warning` or `/wd`. For more information, see [`warning`](../../preprocessor/warning.md) or [`/w`, `/W0`, `/W1`, `/W2`, `/W3`, `/W4`, `/w1`, `/w2`, `/w3`, `/w4`, `/Wall`, `/wd`, `/we`, `/wo`, `/Wv`, `/WX` (Warning Level)](../../build/reference/compiler-option-warning-level.md).
1515

@@ -21,7 +21,6 @@ The following sample generates C4430:
2121
// compile with: /c
2222
struct CMyClass {
2323
CUndeclared m_myClass; // C4430
24-
int m_myClass;
2524
};
2625

2726
typedef struct {
@@ -31,21 +30,4 @@ typedef struct {
3130
} POINT;
3231
```
3332
34-
The following addresses C4430:
35-
36-
```cpp
37-
// compile with: /c
38-
39-
#include "CUndeclared.h" // for `CUndeclared`
40-
41-
struct CMyClass {
42-
CUndeclared m_myClass;
43-
int m_myClass;
44-
};
45-
46-
typedef struct {
47-
int someFunction();
48-
unsigned x;
49-
unsigned y;
50-
} POINT;
51-
```
33+
To fix this code, you'd need to define the type `CUndeclared` and the function `someFunction` prior to their use.

docs/error-messages/compiler-warnings/compiler-warning-level-2-c4146.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
---
22
description: "Learn more about: Compiler warning (level 2) C4146"
33
title: "Compiler warning (level 2) C4146"
4-
ms.date: 08/30/2022
4+
ms.date: 04/22/2025
55
f1_keywords: ["C4146"]
66
helpviewer_keywords: ["C4146"]
77
---
88
# Compiler warning (level 2) C4146
99

1010
> unary minus operator applied to unsigned type, result still unsigned
1111
12-
Unsigned types can hold only non-negative values, so unary minus (negation) usually doesn't make sense when applied to an unsigned type. Both the operand and the result are non-negative.
12+
Unsigned types only hold non-negative values. So unary minus (negation) usually doesn't make sense when applied to an unsigned type. Both the operand and the result are non-negative.
1313

1414
## Remarks
1515

16-
When you express a negative integer literal, the **`-`** in front of the value is parsed as a [unary negation](../../cpp/unary-plus-and-negation-operators-plus-and.md) operator. The compiler applies the operator after it parses the numeric value. If the numeric value fits in the range of an unsigned integer type, but not the corresponding signed integer type, the compiler interprets the value as unsigned. An unsigned value is unchanged by the unary negation operator.
16+
When you express a negative integer literal, the **`-`** in front of the value is parsed as a [unary negation](../../cpp/unary-plus-and-negation-operators-plus-and.md) operator. The compiler applies the operator after it parses the numeric value. If the numeric value fits in the range of an unsigned integer type, but not the corresponding signed integer type, the compiler interprets the value as unsigned.
1717

18-
This warning often occurs when you try to express the minimum **`int`** value, -2147483648, or the minimum **`long long`** value, -9223372036854775808. These values can't be written as -2147483648 or -9223372036854775808ll, respectively. The reason is because the compiler processes the expression in two stages: first, it parses the numeric value, then it applies the negation operator. For example, when the compiler parses -2147483648, it follows these steps:
18+
This warning often occurs when you try to express the minimum **`int`** value, -2147483648, or the minimum **`long long`** value, -9223372036854775808. These values can't be written as -2147483648 or -9223372036854775808ll. The reason is because the compiler processes the expression in two stages: first, it parses the numeric value, then it applies the negation operator. For example, when the compiler parses -2147483648, it follows these steps:
1919

2020
1. The number 2147483648 is evaluated. Because it's greater than the maximum **`int`** value of 2147483647, but still fits in an **`unsigned int`**, the type of 2147483648 is **`unsigned int`**.
21-
2221
1. Unary minus is applied to the unsigned value, with an unsigned result, which also happens to be 2147483648.
2322

2423
The unsigned type of the result can cause unexpected behavior. If the result is used in a comparison, then an unsigned comparison might be used, for example, when the other operand is an **`int`**.
2524

26-
You can avoid C4146 by using `INT_MIN` or `LLONG_MIN` from *`<limits.h>`* or the C++ equivalent, *`<climits>`*. These values have signed types.
25+
You can avoid **C4146** by using `INT_MIN` or `LLONG_MIN` from *`<limits.h>`* or the C++ equivalent, *`<climits>`*. These values have signed types.
2726

2827
The [`/sdl` (Enable Additional Security Checks)](../../build/reference/sdl-enable-additional-security-checks.md) compiler option elevates this warning to an error.
2928

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
---
22
description: "Learn more about: Compiler Warning (level 4) C4100"
33
title: "Compiler Warning (level 4) C4100"
4-
ms.date: "11/04/2016"
4+
ms.date: 04/22/2025
55
f1_keywords: ["C4100"]
66
helpviewer_keywords: ["C4100"]
7-
ms.assetid: 478ed97d-e502-49e4-9afb-ac2a6c61194b
87
---
98
# Compiler Warning (level 4) C4100
109

11-
'identifier' : unreferenced formal parameter
10+
> 'identifier' : unreferenced formal parameter
1211
1312
The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
1413

15-
C4100 can also be issued when code calls a destructor on a otherwise unreferenced parameter of primitive type. This is a limitation of the Microsoft C++ compiler.
14+
C4100 can also be issued when code calls a destructor on an otherwise unreferenced parameter of primitive type.
1615

1716
The following sample generates C4100:
1817

1918
```cpp
2019
// C4100.cpp
2120
// compile with: /W4
22-
void func(int i) { // C4100, delete the unreferenced parameter to
23-
//resolve the warning
21+
void func(int i) { // C4100, delete the unreferenced parameter to resolve the warning
2422
// i; // Or uncomment this line to add a reference
2523
}
2624

0 commit comments

Comments
 (0)