Skip to content

Commit dfd7acc

Browse files
authored
Merge pull request MicrosoftDocs#4565 from corob-msft/learn/corob/ca-acrolinx-3
Fix Code Analysis warning publishing issues
2 parents 9734613 + 87fcae7 commit dfd7acc

28 files changed

+183
-113
lines changed

docs/code-quality/c26138.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
description: "Learn more about: Warning C26138"
33
title: Warning C26138
44
ms.date: 01/14/2019
5-
f1_keywords: ["C26138"]
5+
f1_keywords: ["C26138", "SUSPENDED_WITH_LOCK"]
66
helpviewer_keywords: ["C26138"]
7-
author: sunnychatterjee
8-
ms.author: sunnych
97
---
108
# Warning C26138
119

1210
> Suspending a coroutine while holding lock '*lock*'.
1311
12+
## Remarks
13+
1414
Warning C26138 warns when a coroutine is suspended while holding a lock. In general, we can't know how long will a coroutine remain in the suspended state so this pattern may result in longer critical sections than expected.
1515

16+
Code analysis name: `SUSPENDED_WITH_LOCK`
17+
1618
## Examples
1719

1820
The following code will generate C26138.

docs/code-quality/c26433.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ title: Warning C26433
44
ms.date: 01/18/2017
55
f1_keywords: ["C26433", "OVERRIDE_EXPLICITLY"]
66
helpviewer_keywords: ["C26433"]
7-
dev_langs: ["C++"]
87
---
98
# Warning C26433
109

11-
Function should be marked with `override`
10+
> Function should be marked with `override`
1211
1312
## C++ Core Guidelines
1413

@@ -24,6 +23,8 @@ The rule doesn't flag functions explicitly marked as `final`, which is itself a
2423

2524
Warnings show up on function definitions, not declarations. It may be confusing, since definitions don't have virtual specifiers, but the warning is still correct.
2625

26+
Code analysis name: `OVERRIDE_EXPLICITLY`
27+
2728
## Example: Implicit overriding
2829

2930
```cpp

docs/code-quality/c26435.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ title: Warning C26435
44
ms.date: 01/18/2017
55
f1_keywords: ["C26435", "SINGLE_VIRTUAL_SPECIFICATION"]
66
helpviewer_keywords: ["C26435"]
7-
dev_langs: ["C++"]
87
---
98
# Warning C26435
109

@@ -25,6 +24,8 @@ To improve readability, the kind of virtual behavior should be stated clearly an
2524
- This rule skips destructors since they have special rules regarding virtuality.
2625
- Warnings show up on function definitions, not declarations. It may be confusing, since definitions don't have virtual specifiers, but the warning is still appropriate.
2726

27+
Code analysis name: `SINGLE_VIRTUAL_SPECIFICATION`
28+
2829
## Example: Redundant specifier
2930

3031
```cpp

docs/code-quality/c26443.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ title: Warning C26443
33
ms.date: 01/18/2017
44
f1_keywords: ["C26443", "NO_EXPLICIT_DTOR_OVERRIDE"]
55
helpviewer_keywords: ["C26443"]
6-
dev_langs: ["C++"]
76
description: Warning C26443 Rule concerning overriding destructors
87
---
98
# Warning C26443
109

11-
"Overriding destructor should not use explicit 'override' or 'virtual' specifiers."
10+
> Overriding destructor should not use explicit 'override' or 'virtual' specifiers.
1211
1312
This warning was removed in Visual Studio 16.8 to reflect [changes to C.128 in the C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/pull/1448).
1413

@@ -24,6 +23,8 @@ The current consensus on the Core Guidelines is to exclude destructors from the
2423
- Destructors can still use the 'final' specifier because of its special semantics.
2524
- Warnings show up on function definitions, not declarations. It may be confusing, since definitions don't have virtual specifiers, but the warning is still appropriate.
2625

26+
Code analysis name: `NO_EXPLICIT_DTOR_OVERRIDE`
27+
2728
## Example: Explicit 'override'
2829

2930
```cpp

docs/code-quality/c26444.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ title: Warning C26444
44
ms.date: 01/18/2017
55
f1_keywords: ["C26444", "NO_UNNAMED_RAII_OBJECTS"]
66
helpviewer_keywords: ["C26444"]
7-
dev_langs: ["C++"]
87
---
98
# Warning C26444
109

11-
Avoid unnamed objects with custom construction and destruction.
10+
> Avoid unnamed objects with custom construction and destruction.
1211
1312
## C++ Core Guidelines
1413

@@ -23,6 +22,8 @@ Unnamed (that is, temporary) objects with non-trivial behavior may point to eith
2322
- The logic skips temporaries if they're used in higher-level expressions. One example is temporaries that are passed as arguments or used to invoke a function.
2423
- The standard library implementation may have different versions of destruction logic for some types (for example, containers). This can produce noisy warnings on debug builds because it's customary to ignore iterators returned from calls like [`std::vector::insert`](../standard-library/vector-class.md#insert). While such warnings aren't actionable in most cases, they're legitimate in pointing to the place where some non-obvious work is done in temporary objects.
2524

25+
Code analysis name: `NO_UNNAMED_RAII_OBJECTS`
26+
2627
## Example: Ignored call result
2728

2829
```cpp

docs/code-quality/c26450.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
description: "Learn more about: Arithmetic overflow: '%operator%' operation causes overflow at compile time. Use a wider type to store the operands"
33
title: Warning C26450
44
ms.date: 01/08/2017
5-
f1_keywords: ["C26450"]
5+
f1_keywords: ["C26450", "RESULT_OF_ARITHMETIC_OPERATION_PROVABLY_LOSSY"]
66
helpviewer_keywords: ["C26450"]
7-
dev_langs: ["C++"]
87
---
9-
# Arithmetic overflow: '%operator%' operation causes overflow at compile time. Use a wider type to store the operands
8+
# Warning C26450
9+
10+
>Arithmetic overflow: '*operator*' operation causes overflow at compile time. Use a wider type to store the operands (io.1)
11+
12+
## Remarks
1013

1114
This warning indicates that an arithmetic operation was provably lossy at compile time. It can be asserted when the operands are all compile-time constants. Currently, we check left shift, multiplication, addition, and subtraction operations for such overflows.
1215

1316
Warning C4307 is a similar check in the Microsoft C++ compiler.
1417

18+
Code analysis name: `RESULT_OF_ARITHMETIC_OPERATION_PROVABLY_LOSSY`
19+
1520
## Example 1
1621

1722
```cpp

docs/code-quality/c26451.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
title: Warning C26451
33
description: "Describes the causes of MSVC code analysis warning C26451, and shows how to fix it."
44
ms.date: 07/15/2020
5-
f1_keywords: ["C26451"]
5+
f1_keywords: ["C26451", "RESULT_OF_ARITHMETIC_OPERATION_CAST_TO_LARGER_SIZE"]
66
helpviewer_keywords: ["C26451"]
7-
dev_langs: ["C++"]
87
---
98
# Warning C26451
109

11-
> Arithmetic overflow: Using operator '*operator*' on a *size-a* byte value and then casting the result to a *size-b* byte value. Cast the value to the wider type before calling operator '*operator*' to avoid overflow
10+
> Arithmetic overflow: Using operator '*operator*' on a *size-a* byte value and then casting the result to a *size-b* byte value. Cast the value to the wider type before calling operator '*operator*' to avoid overflow (io.2)
1211
1312
This warning indicates incorrect behavior that results from integral promotion rules and types larger than the ones in which arithmetic is typically performed.
1413

1514
## Remarks
1615

1716
Code analysis detects when an integral value gets shifted left, multiplied, added, or subtracted, and the result gets cast to a wider integral type. If the operation overflows the narrower integral type, then data is lost. You can prevent this loss by casting the value to a wider type before the arithmetic operation.
1817

18+
Code analysis name: `RESULT_OF_ARITHMETIC_OPERATION_CAST_TO_LARGER_SIZE`
19+
1920
## Example 1
2021

2122
The following code generates this warning:

docs/code-quality/c26452.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
title: Warning C26452
33
description: "Describes causes of MSVC Code analysis warning C26452, and how to fix the issue."
44
ms.date: 07/15/2020
5-
f1_keywords: ["C26452"]
5+
f1_keywords: ["C26452", "SHIFT_COUNT_NEGATIVE_OR_TOO_BIG"]
66
helpviewer_keywords: ["C26452"]
7-
dev_langs: ["C++"]
87
---
98
# Warning C26452
109

11-
> Arithmetic overflow: Left shift count is negative or greater than or equal to the operand size, which is undefined behavior
10+
> Arithmetic overflow: Left shift count is negative or greater than or equal to the operand size, which is undefined behavior (io.3)
11+
12+
## Remarks
1213

1314
This warning indicates the shift count is negative, or greater than or equal to the number of bits in the shifted operand. Either case results in undefined behavior.
14-
C4293 is a similar check in the Microsoft C++ compiler.
15+
16+
Warning C4293 is a similar check in the Microsoft C++ compiler.
17+
18+
Code analysis name: `SHIFT_COUNT_NEGATIVE_OR_TOO_BIG`
1519

1620
## Example
1721

docs/code-quality/c26453.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
title: Warning C26453
33
description: "Describes the causes of MSVC code analysis warning C26453, and shows how to fix it."
44
ms.date: 07/15/2020
5-
f1_keywords: ["C26453"]
5+
f1_keywords: ["C26453", "LEFTSHIFT_NEGATIVE_SIGNED_NUMBER"]
66
helpviewer_keywords: ["C26453"]
7-
dev_langs: ["C++"]
87
---
98
# Warning C26453
109

11-
> Arithmetic overflow: Left shift of a negative signed number is undefined behavior
10+
> Arithmetic overflow: Left shift of a negative signed number is undefined behavior (io.4)
11+
12+
## Remarks
1213

1314
This warning indicates the code left shifts a negative signed integral value, which is non-portable and triggers implementation defined behavior.
1415

16+
Code analysis name: `LEFTSHIFT_NEGATIVE_SIGNED_NUMBER`
17+
1518
## Example
1619

1720
```cpp

docs/code-quality/c26454.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
---
2-
description: "Learn more about: Arithmetic overflow: '%operator%' operation produces a negative unsigned result at compile time"
2+
description: "Learn more about: Arithmetic overflow: 'operator' operation produces a negative unsigned result at compile time"
33
title: Warning C26454
44
ms.date: 01/08/2017
5-
f1_keywords: ["C26454"]
5+
f1_keywords: ["C26454", "RESULT_OF_ARITHMETIC_OPERATION_NEGATIVE_UNSIGNED"]
66
helpviewer_keywords: ["C26454"]
7-
dev_langs: ["C++"]
87
---
9-
# Arithmetic overflow: '%operator%' operation produces a negative unsigned result at compile time
8+
# Warning C26454
109

11-
This warning indicates that the subtraction operation produces a negative result that was evaluated in an unsigned context, which can result in unintended overflows.
10+
> Arithmetic overflow: '*operator*' operation produces a negative unsigned result at compile time
11+
12+
## Remarks
13+
14+
This warning indicates that the subtraction operation produces a negative result that was evaluated in an unsigned context, which can result in unintended overflows.
15+
16+
Code analysis name: `RESULT_OF_ARITHMETIC_OPERATION_NEGATIVE_UNSIGNED`
1217

1318
## Example
1419

docs/code-quality/c26478.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
---
22
description: "Learn more about: Warning C26478: Don't use std::move on constant variables. (es.56)"
3-
title: c26478
4-
keywords: c26478
3+
title: Warning C26478
54
ms.date: 07/15/2019
6-
f1_keywords: ["C26478"]
5+
f1_keywords: ["C26478", "NO_MOVE_OP_ON_CONST"]
76
helpviewer_keywords: ["C26478"]
8-
dev_langs: ["C++"]
97
---
108
# Warning C26478
119

12-
> Don't use std::move on constant variables. (es.56)
10+
> Don't use `std::move` on constant variables. (es.56)
1311
14-
This warning is to indicate that the use of std::move not consistent with how std::move is intended to be used.
12+
## Remarks
1513

16-
When called on a const object, std::move returns a copy of the object, which is likely not the developer's intent.
14+
This warning is to indicate that the use of `std::move` not consistent with how `std::move` is intended to be used.
15+
16+
When called on a `const` object, `std::move` returns a copy of the object, which is likely not the developer's intent.
17+
18+
Code analysis name: `NO_MOVE_OP_ON_CONST`
1719

1820
## Example 1
1921

docs/code-quality/c26800.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
description: "Learn more about: Warning C26800"
33
title: Warning C26800
44
ms.date: 01/14/2019
5-
f1_keywords: ["C26800"]
5+
f1_keywords: ["C26800", "USE_OF_A_MOVED_FROM_OBJECT"]
66
helpviewer_keywords: ["C26800"]
7-
author: sunnychatterjee
8-
ms.author: sunnych
97
---
108
# Warning C26800
119

1210
> Use of a moved from object: '*object*'.
1311
14-
Warning C26800 is triggered when variable is used after it has been moved from. A variable is considered moved from after it was passed to a function as rvalue reference. There are some legitimate exceptions for uses such as assignment, destruction, and some state resetting functions such as std::vector::clear.
12+
## Remarks
13+
14+
Warning C26800 is triggered when variable is used after it has been moved from. A variable is considered moved from after it was passed to a function as rvalue reference. There are some legitimate exceptions for uses such as assignment, destruction, and some state resetting functions such as `std::vector::clear`.
15+
16+
Code analysis name: `USE_OF_A_MOVED_FROM_OBJECT`
1517

1618
## Examples
1719

docs/code-quality/c26810.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
description: "Learn more about: Warning C26810"
33
title: Warning C26810
44
ms.date: 01/14/2019
5-
f1_keywords: ["C26810"]
5+
f1_keywords: ["C26810", "COROUTINES_USE_AFTER_FREE_CAPTURE"]
66
helpviewer_keywords: ["C26810"]
7-
author: sunnychatterjee
8-
ms.author: sunnych
97
---
108
# Warning C26810
119

1210
> Lifetime of captured variable '*var*' might end by the time the coroutine is resumed.
1311
12+
## Remarks
13+
1414
Warning C26810 is triggered when a memory region might be used after it went out of scope in a resumed coroutine.
1515

16+
Code analysis name: `COROUTINES_USE_AFTER_FREE_CAPTURE`
17+
1618
## Example
1719

1820
The following code will generate C26810.

docs/code-quality/c26811.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
description: "Learn more about: Warning C26811"
33
title: Warning C26811
44
ms.date: 01/14/2019
5-
f1_keywords: ["C26811"]
5+
f1_keywords: ["C26811", "COROUTINES_USE_AFTER_FREE_PARAM"]
66
helpviewer_keywords: ["C26811"]
7-
author: sunnychatterjee
8-
ms.author: sunnych
97
---
108
# Warning C26811
119

1210
> Lifetime of the memory referenced by parameter '*var*' might end by the time the coroutine is resumed.
1311
12+
## Remarks
13+
1414
Warning C26811 is triggered when a memory region might be used after it went out of scope in a resumed coroutine.
1515

16+
Code analysis name: `COROUTINES_USE_AFTER_FREE_PARAM`
17+
1618
## Example
1719

1820
The following code will generate C26811.

docs/code-quality/c26812.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
---
22
description: "Learn more about: Warning C26812"
3-
title: c26812
4-
keywords: c26812
3+
title: Warning C26812
54
ms.date: 02/14/2022
6-
f1_keywords: ["C26812"]
5+
f1_keywords: ["C26812", "PreferScopedEnum"]
76
helpviewer_keywords: ["C26812"]
8-
dev_langs: ["C++"]
97
---
108
# Warning C26812
119

12-
> Prefer 'enum class' over 'enum' (Enum.3)
10+
> The enum type '*type-name*' is unscoped. Prefer 'enum class' over 'enum' (Enum.3)
1311
14-
The `enum` type *type-name* is unscoped. Prefer `enum class` over `enum` (Enum.3)
12+
## Remarks
13+
14+
Prefer `enum class` over `enum` to prevent pollution in the global namespace.
15+
16+
Code analysis name: `PreferScopedEnum`
1517

1618
## Example
1719

docs/code-quality/c26813.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
---
22
description: "Learn more about: Warning C26813"
3-
title: c26813
3+
title: Warning C26813
44
ms.date: 03/02/2022
5-
f1_keywords: ["C26813"]
5+
f1_keywords: ["C26813", "USE_BITWISE_AND_TO_CHEK_ENUM_FLAGS", "USE_BITWISE_AND_TO_CHECK_ENUM_FLAGS"]
66
helpviewer_keywords: ["C26813"]
77
---
88
# Warning C26813
99

1010
> Use 'bitwise and' to check if a flag is set
1111
12+
## Remarks
13+
1214
Most `enum` types with power of two member values are intended to be used as bit flags. As a result, you rarely want to compare these flags for equality. Instead, extract the bits you're interested in by using bitwise operations.
1315

16+
Code analysis name: `USE_BITWISE_AND_TO_CHEK_ENUM_FLAGS`
17+
1418
## Example
1519

1620
```cpp

0 commit comments

Comments
 (0)