Skip to content

Commit b506367

Browse files
authored
Add "Remarks" headings for warning references in range [C6251, C6310]
1 parent 2643b99 commit b506367

File tree

13 files changed

+26
-24
lines changed

13 files changed

+26
-24
lines changed

docs/code-quality/c6255.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: bb6430b2-782a-4410-a8e1-609df06007de
1010

1111
> _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
1212
13-
This warning indicates that a call to `_alloca` has been detected outside of local exception handling.
14-
1513
## Remarks
1614

15+
This warning indicates that a call to `_alloca` has been detected outside of local exception handling.
16+
1717
`_alloca` should always be called from within the protected range of an exception handler because it can raise a stack overflow exception on failure. If possible, instead of using `_alloca`, consider using `_malloca`, which is a more secure version of `_alloca`.
1818

1919
Code analysis name: `UNPROTECTEDUSEOFALLOCA`

docs/code-quality/c6258.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: 62f3eed7-d9cd-46eb-8c38-0bc4f647941f
1010

1111
> Using `TerminateThread` does not allow proper thread clean up.
1212
13-
This warning indicates that a call to `TerminateThread` has been detected.
14-
1513
## Remarks
1614

15+
This warning indicates that a call to `TerminateThread` has been detected.
16+
1717
`TerminateThread` is a dangerous function that should only be used in the most extreme cases. For more information about problems associated with TerminateThread call, see [`TerminateThread` function](/windows/desktop/api/processthreadsapi/nf-processthreadsapi-terminatethread).
1818

1919
Code analysis name: `USINGTERMINATETHREAD`

docs/code-quality/c6260.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: 9cbedfcb-32b2-4fe4-99f7-a2d4a7f4422a
1010

1111
> `sizeof` * `sizeof` is almost always wrong, did you intend to use a character count or a byte count?
1212
13-
This warning indicates that the results of two **`sizeof`** operations have been multiplied together.
14-
1513
## Remarks
1614

15+
This warning indicates that the results of two **`sizeof`** operations have been multiplied together.
16+
1717
The C/C++ **`sizeof`** operator returns the number of bytes of storage an object uses. It's typically incorrect to multiply it by another **`sizeof`** operation. Usually, you're interested in the number of bytes in an object or the number of elements in an array (for example, the number of wide-characters in an array).
1818

1919
There's some unintuitive behavior associated with **`sizeof`** operator. For example, in C, `sizeof ('\0') == 4`, because a character is of an integral type. In C++, the type of a character literal is **`char`**, so `sizeof ('\0') == 1`. However, in both C and C++, the following relation is true:

docs/code-quality/c6268.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: fd81e00a-de2f-498b-b3fe-53ce056042d7
1010

1111
> Incorrect order of operations: ('*TYPE1*')('*TYPE2*')x + y. Possible missing parentheses in ('*TYPE1*')(('*TYPE2*')x + y)
1212
13-
This warning indicates that a complex cast expression might involve a precedence problem when performing pointer arithmetic. Because casts group more closely than binary operators, the result might not be what the programmer intended. In some cases, this defect causes incorrect behavior or a program crash.
14-
1513
## Remarks
1614

15+
This warning indicates that a complex cast expression might involve a precedence problem when performing pointer arithmetic. Because casts group more closely than binary operators, the result might not be what the programmer intended. In some cases, this defect causes incorrect behavior or a program crash.
16+
1717
In an expression such as:
1818

1919
```cpp

docs/code-quality/c6269.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: a01fa7fa-fc6c-4af7-ac8c-585e44e60cca
1010

1111
> Possible incorrect order of operations: dereference ignored
1212
13-
This warning indicates that the result of a pointer dereference is being ignored, which raises the question of why the pointer is being dereferenced in the first place.
14-
1513
## Remarks
1614

15+
This warning indicates that the result of a pointer dereference is being ignored, which raises the question of why the pointer is being dereferenced in the first place.
16+
1717
The compiler will correctly optimize away the gratuitous dereference. In some cases, however, this defect may reflect a precedence or logic error.
1818

1919
One common cause for this defect is an expression statement of the form:

docs/code-quality/c6276.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: 88f288da-da81-4d32-ab0f-be9d01a2606a
1010

1111
> Cast between semantically different string types. Use of invalid string can lead to undefined behavior.
1212
13-
This warning indicates a potentially incorrect cast from a narrow character string (`char*`) to a wide character string (`wchar_t*`).
14-
1513
## Remarks
1614

15+
This warning indicates a potentially incorrect cast from a narrow character string (`char*`) to a wide character string (`wchar_t*`).
16+
1717
Because the Microsoft compiler implements wide strings with a character size of 2 bytes, casting from a narrow string might produce strings that aren't correctly terminated. If you use such strings with the `wcs*` functions in the runtime library, they could cause buffer overruns and access violations.
1818

1919
Code analysis name: `CHAR_TO_WCHAR_CAST`

docs/code-quality/c6277.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: 2b41252a-68c2-4e92-b005-0458db5f4430
1010

1111
> NULL application name with an unquoted path in call to '*function-name*': results in a security vulnerability if the path contains spaces
1212
13-
This warning indicates that the application name parameter is null and that there might be spaces in the executable path name.
14-
1513
## Remarks
1614

15+
This warning indicates that the application name parameter is null and that there might be spaces in the executable path name.
16+
1717
Unless the executable name is fully qualified, there's likely to be a security problem. A malicious user could insert a rogue executable with the same name earlier in the path. To correct this warning, you can specify the application name instead of passing null. Alternatively, if you do pass null for the application name, use quotation marks around the executable path.
1818

1919
Code analysis name: `CREATEPROCESS_ESCAPE`

docs/code-quality/c6279.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: 0af88b58-35df-456f-8c02-e8eeffe3b7de
1010

1111
> '*variable-name*' is allocated with scalar new, deleted with array delete []
1212
13-
This warning appears only in C++ code and indicates that the calling function has inconsistently allocated memory with the scalar `new` operator, but freed it with the array `delete[]` operator. If memory is allocated with scalar `new`, it should typically be freed with scalar `delete`.
14-
1513
## Remarks
1614

15+
This warning appears only in C++ code and indicates that the calling function has inconsistently allocated memory with the scalar `new` operator, but freed it with the array `delete[]` operator. If memory is allocated with scalar `new`, it should typically be freed with scalar `delete`.
16+
1717
The exact ramifications of this defect are difficult to predict. It might cause random behavior or crashes due to usage of uninitialized memory as constructors aren't invoked. Or, it might cause memory allocations and crashes in situations where operators have been overridden. The analysis tool doesn't currently distinguish between these situations.
1818

1919
To avoid these kinds of allocation problems altogether, use the mechanisms that are provided by the C++ Standard Library (STL). These include [`shared_ptr`](../standard-library/shared-ptr-class.md), [`unique_ptr`](../standard-library/unique-ptr-class.md), and containers such as [`vector`](../standard-library/vector.md). For more information, see [Smart pointers](../cpp/smart-pointers-modern-cpp.md) and [C++ Standard Library](../standard-library/cpp-standard-library-reference.md).

docs/code-quality/c6280.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: b91f2966-0876-4c9b-843a-e142f35be864
1010

1111
> '*variable-name*' is allocated with '*function-name-1*', but deleted with '*function-name-2*'
1212
13-
This warning indicates that the calling function has inconsistently allocated memory by using a function from one family and freed it by using a function from another.
14-
1513
## Remarks
1614

15+
This warning indicates that the calling function has inconsistently allocated memory by using a function from one family and freed it by using a function from another.
16+
1717
The analyzer checks for this condition only when the `_Analysis_mode_(_Analysis_local_leak_checks_)` SAL annotation is specified. By default, this annotation is specified for Windows kernel mode (driver) code. For more information about SAL annotations, see [Using SAL Annotations to Reduce C/C++ Code Defects](../code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.md).
1818

1919
For example, this warning would be produced if memory is allocated by using `malloc` but freed by using `GlobalFree` or `delete`. In the specific cases of mismatches between array `new[]` and scalar `delete`, more precise warnings are reported instead of this one.

docs/code-quality/c6283.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.assetid: 7760d32e-6d71-4c81-a6d2-719c9c76c2bb
1010

1111
> '*variable-name*' is allocated with array new [], but deleted with scalar delete
1212
13-
This warning appears only in C++ code and indicates that the calling function has inconsistently allocated memory with the array `new []` operator, but freed it with the scalar `delete` operator.
14-
1513
## Remarks
1614

15+
This warning appears only in C++ code and indicates that the calling function has inconsistently allocated memory with the array `new []` operator, but freed it with the scalar `delete` operator.
16+
1717
This defect might cause leaks, memory corruptions, and, in situations where operators have been overridden, crashes. If memory is allocated with array `new []`, it should typically be freed with array `delete[]`.
1818

1919
Warning C6283 only applies to arrays of primitive types such as integers or characters. If elements of the array are objects of class type then warning [C6278](../code-quality/c6278.md) is issued.

0 commit comments

Comments
 (0)