Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/code-quality/c6255.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6255"
description: "Learn more about: Warning C6255"
title: Warning C6255
ms.date: 11/04/2016
f1_keywords: ["C6255", "UNPROTECTEDUSEOFALLOCA", "__WARNING_UNPROTECTEDUSEOFALLOCA"]
helpviewer_keywords: ["C6255"]
ms.assetid: bb6430b2-782a-4410-a8e1-609df06007de
---
# Warning C6255

> _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead

This warning indicates that a call to `_alloca` has been detected outside of local exception handling.

## Remarks

This warning indicates that a call to `_alloca` has been detected outside of local exception handling.

`_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`.

Code analysis name: `UNPROTECTEDUSEOFALLOCA`
Expand Down
7 changes: 3 additions & 4 deletions docs/code-quality/c6258.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6258"
description: "Learn more about: Warning C6258"
title: Warning C6258
ms.date: 11/04/2016
f1_keywords: ["C6258", "USINGTERMINATETHREAD", "__WARNING_USINGTERMINATETHREAD"]
helpviewer_keywords: ["C6258"]
ms.assetid: 62f3eed7-d9cd-46eb-8c38-0bc4f647941f
---
# Warning C6258

> Using `TerminateThread` does not allow proper thread clean up.

This warning indicates that a call to `TerminateThread` has been detected.

## Remarks

This warning indicates that a call to `TerminateThread` has been detected.

`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).

Code analysis name: `USINGTERMINATETHREAD`
Expand Down
5 changes: 2 additions & 3 deletions docs/code-quality/c6259.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
title: "Warning C6259"
description: "Learn more about: Warning C6259"
title: Warning C6259
ms.date: 11/04/2016
f1_keywords: ["C6259", "DEADCODEINBITORLIMITEDSWITCH", "__WARNING_DEADCODEINBITORLIMITEDSWITCH"]
helpviewer_keywords: ["C6259"]
ms.assetid: a370bfd2-6634-402c-84c7-3d83fa0009b7
---
# Warning C6259

Expand All @@ -18,7 +17,7 @@ Code analysis name: `DEADCODEINBITORLIMITEDSWITCH`

## Example

The following sample code generates this warning because the 'switch' expression `(rand() & 3)` can't evaluate to case label (`case 4`):
The following example code generates this warning because the 'switch' expression `(rand() & 3)` can't evaluate to case label (`case 4`):

```cpp
#include <stdlib.h>
Expand Down
7 changes: 3 additions & 4 deletions docs/code-quality/c6260.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6260"
description: "Learn more about: Warning C6260"
title: Warning C6260
ms.date: 11/04/2016
f1_keywords: ["C6260", "USEOFBYTEAREA", "__WARNING_USEOFBYTEAREA"]
helpviewer_keywords: ["C6260"]
ms.assetid: 9cbedfcb-32b2-4fe4-99f7-a2d4a7f4422a
---
# Warning C6260

> `sizeof` * `sizeof` is almost always wrong, did you intend to use a character count or a byte count?

This warning indicates that the results of two **`sizeof`** operations have been multiplied together.

## Remarks

This warning indicates that the results of two **`sizeof`** operations have been multiplied together.

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

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:
Expand Down
2 changes: 1 addition & 1 deletion docs/code-quality/c6262.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Warning C6262
title: "Warning C6262"
description: "Visual Studio C++ Code Analysis warning C6262 description and resolution."
ms.date: 10/14/2020
f1_keywords: ["C6262", "EXCESSIVESTACKUSAGE", "__WARNING_EXCESSIVESTACKUSAGE"]
Expand Down
3 changes: 1 addition & 2 deletions docs/code-quality/c6263.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
title: "Warning C6263"
description: "Learn more about: Warning C6263"
title: Warning C6263
ms.date: 11/04/2016
f1_keywords: ["C6263", "USINGALLOCAINLOOP", "__WARNING_USINGALLOCAINLOOP"]
helpviewer_keywords: ["C6263"]
ms.assetid: bc360ad7-5f59-4480-a642-6c7e6beeb5f6
---
# Warning C6263

Expand Down
7 changes: 3 additions & 4 deletions docs/code-quality/c6268.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6268"
description: "Learn more about: Warning C6268"
title: Warning C6268
ms.date: 11/04/2016
f1_keywords: ["C6268", "MISPARENTHESIZED_CASTS", "__WARNING_MISPARENTHESIZED_CASTS"]
helpviewer_keywords: ["C6268"]
ms.assetid: fd81e00a-de2f-498b-b3fe-53ce056042d7
---
# Warning C6268

> Incorrect order of operations: ('*TYPE1*')('*TYPE2*')x + y. Possible missing parentheses in ('*TYPE1*')(('*TYPE2*')x + y)

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.

## Remarks

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.

In an expression such as:

```cpp
Expand Down
7 changes: 3 additions & 4 deletions docs/code-quality/c6269.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6269"
description: "Learn more about: Warning C6269"
title: Warning C6269
ms.date: 11/04/2016
f1_keywords: ["C6269", "POINTER_DEREF_DISCARDED", "__WARNING_POINTER_DEREF_DISCARDED"]
helpviewer_keywords: ["C6269"]
ms.assetid: a01fa7fa-fc6c-4af7-ac8c-585e44e60cca
---
# Warning C6269

> Possible incorrect order of operations: dereference ignored

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.

## Remarks

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.

The compiler will correctly optimize away the gratuitous dereference. In some cases, however, this defect may reflect a precedence or logic error.

One common cause for this defect is an expression statement of the form:
Expand Down
2 changes: 1 addition & 1 deletion docs/code-quality/c6270.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Warning C6270"
description: "Learn more about: Warning C6270"
title: Warning C6270
ms.date: 3/03/2023
f1_keywords: ["C6270", "MISSING_FLOAT_ARGUMENT_TO_FORMAT_FUNCTION", "__WARNING_MISSING_FLOAT_ARGUMENT_TO_FORMAT_FUNCTION"]
helpviewer_keywords: ["C6270"]
Expand Down
6 changes: 3 additions & 3 deletions docs/code-quality/c6271.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Warning C6271"
description: "Learn more about: Warning C6271"
title: Warning C6271
ms.date: 3/06/2023
f1_keywords: ["C6271", "EXTRA_ARGUMENT_TO_FORMAT_FUNCTION", "__WARNING_EXTRA_ARGUMENT_TO_FORMAT_FUNCTION"]
helpviewer_keywords: ["C6271"]
Expand All @@ -17,7 +17,7 @@ Code analysis name: `EXTRA_ARGUMENT_TO_FORMAT_FUNCTION`

## Example

The following sample code generates this warning:
The following example code generates this warning:

```cpp
#include <stdio.h>
Expand All @@ -43,7 +43,7 @@ void f()
}
```

The following sample code calls the safe string manipulation function, `sprintf_s`, to correct this warning:
The following example code calls the safe string manipulation function, `sprintf_s`, to correct this warning:

```cpp
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion docs/code-quality/c6272.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Warning C6272"
description: "Learn more about: Warning C6272"
title: Warning C6272
ms.date: 03/07/2023
f1_keywords: ["C6272", "NON_FLOAT_ARGUMENT_TO_FORMAT_FUNCTION", "__WARNING_NON_FLOAT_ARGUMENT_TO_FORMAT_FUNCTION"]
helpviewer_keywords: ["C6272"]
Expand Down
2 changes: 1 addition & 1 deletion docs/code-quality/c6273.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Warning C6273"
description: "Learn more about: Warning C6273"
title: Warning C6273
ms.date: 03/07/2023
f1_keywords: ["C6273", "NON_INTEGER_ARGUMENT_TO_FORMAT_FUNCTION", "__WARNING_NON_INTEGER_ARGUMENT_TO_FORMAT_FUNCTION"]
helpviewer_keywords: ["C6273"]
Expand Down
2 changes: 1 addition & 1 deletion docs/code-quality/c6274.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Warning C6274"
description: "Learn more about: Warning C6274"
title: Warning C6274
ms.date: 03/07/2023
f1_keywords: ["C6274", "NON_CHAR_ARGUMENT_TO_FORMAT_FUNCTION", "__WARNING_NON_CHAR_ARGUMENT_TO_FORMAT_FUNCTION"]
helpviewer_keywords: ["C6274"]
Expand Down
7 changes: 3 additions & 4 deletions docs/code-quality/c6276.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6276"
description: "Learn more about: Warning C6276"
title: Warning C6276
ms.date: 09/28/2022
f1_keywords: ["C6276", "CHAR_TO_WCHAR_CAST", "__WARNING_CHAR_TO_WCHAR_CAST"]
helpviewer_keywords: ["C6276"]
ms.assetid: 88f288da-da81-4d32-ab0f-be9d01a2606a
---
# Warning C6276

> Cast between semantically different string types. Use of invalid string can lead to undefined behavior.

This warning indicates a potentially incorrect cast from a narrow character string (`char*`) to a wide character string (`wchar_t*`).

## Remarks

This warning indicates a potentially incorrect cast from a narrow character string (`char*`) to a wide character string (`wchar_t*`).

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.

Code analysis name: `CHAR_TO_WCHAR_CAST`
Expand Down
9 changes: 4 additions & 5 deletions docs/code-quality/c6277.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
---
title: "Warning C6277"
description: "Learn more about: Warning C6277"
title: Warning C6277
ms.date: 09/28/2022
f1_keywords: ["C6277", "CREATEPROCESS_ESCAPE", "__WARNING_CREATEPROCESS_ESCAPE"]
helpviewer_keywords: ["C6277"]
ms.assetid: 2b41252a-68c2-4e92-b005-0458db5f4430
---
# Warning C6277

> NULL application name with an unquoted path in call to '*function-name*': results in a security vulnerability if the path contains spaces

This warning indicates that the application name parameter is null and that there might be spaces in the executable path name.

## Remarks

This warning indicates that the application name parameter is null and that there might be spaces in the executable path name.

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.

Code analysis name: `CREATEPROCESS_ESCAPE`

## Example

The following sample code generates warning C6277. The warning is caused by the NULL application name and from the executable path name having a space. Due to how the function parses spaces, there's a risk that a different executable could be run. For more information, see [`CreateProcessA`](/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa).
The following example code generates warning C6277. The warning is caused by the NULL application name and from the executable path name having a space. Due to how the function parses spaces, there's a risk that a different executable could be run. For more information, see [`CreateProcessA`](/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa).

```cpp
#include <windows.h>
Expand Down
7 changes: 3 additions & 4 deletions docs/code-quality/c6278.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
title: "Warning C6278"
description: "Learn more about: Warning C6278"
title: Warning C6278
ms.date: 10/03/2022
f1_keywords: ["C6278", "ARRAY_NEW_DELETE_MISMATCH", "__WARNING_ARRAY_NEW_DELETE_MISMATCH"]
helpviewer_keywords: ["C6278"]
ms.assetid: 5cc3c393-c48a-4f91-9f38-03d7868be5e5
---
# Warning C6278

Expand All @@ -30,7 +29,7 @@ Code analysis name: `ARRAY_NEW_DELETE_MISMATCH`

## Example

The following sample code generates warning C6278:
The following example code generates warning C6278:

```cpp
class A
Expand All @@ -46,7 +45,7 @@ void f( )
}
```

To correct this warning, use the following sample code:
To correct this warning, use the following example code:

```cpp
void f( )
Expand Down
7 changes: 3 additions & 4 deletions docs/code-quality/c6279.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6279"
description: "Learn more about: Warning C6279"
title: Warning C6279
ms.date: 10/03/2022
f1_keywords: ["C6279", "NEW_ARRAY_DELETE_MISMATCH", "__WARNING_NEW_ARRAY_DELETE_MISMATCH"]
helpviewer_keywords: ["C6279"]
ms.assetid: 0af88b58-35df-456f-8c02-e8eeffe3b7de
---
# Warning C6279

> '*variable-name*' is allocated with scalar new, deleted with array delete []

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

## Remarks

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

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.

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).
Expand Down
9 changes: 4 additions & 5 deletions docs/code-quality/c6280.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6280"
description: "Learn more about: Warning C6280"
title: Warning C6280
ms.date: 10/03/2022
f1_keywords: ["C6280", "MEMORY_ALLOCATION_MISMATCH", "__WARNING_MEMORY_ALLOCATION_MISMATCH"]
helpviewer_keywords: ["C6280"]
ms.assetid: b91f2966-0876-4c9b-843a-e142f35be864
---
# Warning C6280

> '*variable-name*' is allocated with '*function-name-1*', but deleted with '*function-name-2*'

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.

## Remarks

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.

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

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.
Expand All @@ -22,7 +21,7 @@ Code analysis name: `MEMORY_ALLOCATION_MISMATCH`

## Example

The following sample code generates this warning. `pInt` is allocated using `calloc` but is freed using the mismatched function `delete`:
The following example code generates this warning. `pInt` is allocated using `calloc` but is freed using the mismatched function `delete`:

```cpp
// C6280a_warning.cpp
Expand Down
3 changes: 1 addition & 2 deletions docs/code-quality/c6281.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
title: "Warning C6281"
description: "Learn more about: Warning C6281"
title: Warning C6281
ms.date: 11/04/2016
f1_keywords: ["C6281", "BITWISERELATIONPRECEDENCEERROR", "__WARNING_BITWISERELATIONPRECEDENCEERROR"]
helpviewer_keywords: ["C6281"]
ms.assetid: d0182269-8403-486b-ac3f-325522871bb1
---
# Warning C6281

Expand Down
3 changes: 1 addition & 2 deletions docs/code-quality/c6282.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
title: "Warning C6282"
description: "Learn more about: Warning C6282"
title: Warning C6282
ms.date: 11/04/2016
f1_keywords: ["C6282", "ASSIGNMENTREPLACESTEST", "__WARNING_ASSIGNMENTREPLACESTEST"]
helpviewer_keywords: ["C6282"]
ms.assetid: 7dc153d5-fb9f-424a-8afa-4e2661efa51c
---
# Warning C6282

Expand Down
7 changes: 3 additions & 4 deletions docs/code-quality/c6283.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
title: "Warning C6283"
description: "Learn more about: Warning C6283"
title: Warning C6283
ms.date: 10/03/2022
f1_keywords: ["C6283", "PRIMITIVE_ARRAY_NEW_DELETE_MISMATCH", "__WARNING_PRIMITIVE_ARRAY_NEW_DELETE_MISMATCH"]
helpviewer_keywords: ["C6283"]
ms.assetid: 7760d32e-6d71-4c81-a6d2-719c9c76c2bb
---
# Warning C6283

> '*variable-name*' is allocated with array new [], but deleted with scalar delete

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.

## Remarks

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.

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[]`.

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.
Expand Down
Loading