Skip to content

Commit f1117d0

Browse files
authored
Merge pull request #5946 from MicrosoftDocs/FromPublicMasterBranch
Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main)
2 parents cc9fe37 + 1a5be4b commit f1117d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+230
-238
lines changed

docs/code-quality/c26409.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
2-
description: "Learn more about CppCoreCheck rule C26409: avoid explicit new and delete."
32
title: Warning C26409
3+
description: "Learn more about CppCoreCheck rule C26409: avoid explicit new and delete."
44
ms.date: 12/14/2020
55
f1_keywords: ["C26409", "NO_NEW_DELETE"]
66
helpviewer_keywords: ["C26409"]
7-
ms.assetid: a3b3a229-d566-4be3-bd28-2876ccc8dc37
87
---
98
# Warning C26409
109

@@ -13,7 +12,7 @@ ms.assetid: a3b3a229-d566-4be3-bd28-2876ccc8dc37
1312
Even if code is clean of calls to `malloc` and `free`, we still suggest that you consider better options than explicit use of operators [`new` and `delete`](../cpp/new-and-delete-operators.md).
1413

1514
**C++ Core Guidelines**:\
16-
[R.11: Avoid calling new and delete explicitly](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly)
15+
[R.11: Avoid calling `new` and `delete` explicitly](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r11-avoid-calling-new-and-delete-explicitly)
1716

1817
The ultimate fix is to use smart pointers and appropriate factory functions, such as [`std::make_unique`](../standard-library/memory-functions.md#make_unique).
1918

docs/code-quality/c26414.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ description: "Reference for Visual Studio C++ Core Guidelines code analysis warn
44
ms.date: 01/29/2020
55
f1_keywords: ["C26414", "RESET_LOCAL_SMART_PTR"]
66
helpviewer_keywords: ["C26414"]
7-
ms.assetid: dd875d0c-6752-4491-a533-3e8831795fbc
87
---
98
# Warning C26414
109

1110
> "Move, copy, reassign or reset a local smart pointer."
1211
1312
**C++ Core Guidelines**:\
14-
[R.5: Prefer scoped objects, don't heap-allocate unnecessarily](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-scoped)
13+
[R.5: Prefer scoped objects, don't heap-allocate unnecessarily](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r5-prefer-scoped-objects-dont-heap-allocate-unnecessarily)
1514

1615
Smart pointers are convenient for dynamic resource management, but they're not always necessary. For example, it may be easier and more efficient to manage a local dynamic buffer by using a standard container. You may not need dynamic allocation at all for single objects, for example, if they never outlive their creator function. They can be replaced with local variables. Smart pointers become handy when a scenario requires a change of ownership. For example, when you reassign a dynamic resource multiple times, or in multiple paths. They're also useful for resources obtained from external code. And, when smart pointers are used to extend the lifetime of a resource.
1716

docs/code-quality/c26432.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ description: "Microsoft C++ Code Analysis warning C26432 for the C++ Core Guidel
44
ms.date: 11/15/2017
55
f1_keywords: ["C26432", "DEFINE_OR_DELETE_SPECIAL_OPS"]
66
helpviewer_keywords: ["C26432"]
7-
ms.assetid: f587b05a-5c69-4176-baa6-fcb79d228b24
87
---
98
# Warning C26432
109

1110
> `If you define or delete any default operation in the type 'type-name', define or delete them all (c.21).`
1211
1312
**C++ Core Guidelines**:\
14-
[C.21: If you define or =delete any default operation, define or =delete them all](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all)
13+
[C.21: If you define or `=delete` any copy, move, or destructor function, define or `=delete` them all](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c21-if-you-define-or-delete-any-copy-move-or-destructor-function-define-or-delete-them-all)
1514

1615
Special operations such as constructors are assumed to alter the behavior of types so they rely more on language mechanisms to automatically enforce specific scenarios. The canonical example is resource management. If you explicitly define, default, or delete any of these special operations, it signals you want to avoid any special handling of a type. It's inconsistent to leave the other operations unspecified, that is, implicitly defined as deleted by the compiler.
1716

docs/code-quality/c26437.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ description: "Learn more about: Warning C26437 DONT_SLICE"
44
ms.date: 05/17/2023
55
f1_keywords: ["C26437", "DONT_SLICE"]
66
helpviewer_keywords: ["C26437"]
7-
ms.assetid: ed2f55bc-a6d8-4cc4-8069-5c96e581a96a
87
---
98
# Warning C26437
109

1110
> Do not slice.
1211
1312
**C++ Core Guidelines**:
14-
[ES.63: Don't slice](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-slice)
13+
[ES.63: Don't slice](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es63-dont-slice)
1514

1615
The language allows [slicing](https://en.wikipedia.org/wiki/Object_slicing) and can be viewed as a special case of a dangerous implicit cast. Even if it's done intentionally and doesn't lead to immediate issues, it's still highly discouraged. It makes code harder to change, by forcing extra requirements on related data types. It's especially true if types are polymorphic or involve resource management.
1716

docs/code-quality/c26439.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ description: CppCoreCheck rule C26439 that enforces C++ Core Guidelines F.6
44
ms.date: 05/17/2023
55
f1_keywords: ["C26439", "SPECIAL_NOEXCEPT"]
66
helpviewer_keywords: ["C26439"]
7-
ms.assetid: 9df2a1b0-ea94-4884-9d28-c1522ec33a1b
87
---
98
# Warning C26439
109

1110
> This kind of function may not throw. Declare it 'noexcept'.
1211
13-
[**C++ Core Guidelines** F.6](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-noexcept): If your function must not throw, declare it `noexcept`
12+
[F.6: If your function must not throw, declare it `noexcept`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f6-if-your-function-must-not-throw-declare-it-noexcept)
1413

1514
Some operations should never throw exceptions. Their implementations should be reliable and should handle possible errors conditions gracefully. They shouldn't use exceptions to indicate failure. This rule flags cases where such operations aren't explicitly marked as `noexcept`, which means that they may throw exceptions and consumers can't make assumptions about its reliability.
1615

@@ -63,5 +62,5 @@ struct S
6362

6463
## See also
6564

66-
[C26455](./c26455.md)\
67-
[**C++ Core Guidelines** F.6](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-noexcept)
65+
[C26455](c26455.md)\
66+
[F.6: If your function must not throw, declare it `noexcept`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f6-if-your-function-must-not-throw-declare-it-noexcept)

docs/code-quality/c26441.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ helpviewer_keywords: ["C26441"]
1111
1212
## C++ Core Guidelines
1313

14-
[CP.44](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cp44-remember-to-name-your-lock_guards-and-unique_locks): Remember to name your `lock_guard`s and `unique_lock`s
14+
[CP.44: Remember to name your `lock_guard`s and `unique_lock`s](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cp44-remember-to-name-your-lock_guards-and-unique_locks)
1515

1616
## Remarks
1717

docs/code-quality/c26444.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ helpviewer_keywords: ["C26444"]
1111
1212
## C++ Core Guidelines
1313

14-
[ES.84: Don't (try to) declare a local variable with no name](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-noname)
14+
[ES.84: Don't try to declare a local variable with no name](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es84-dont-try-to-declare-a-local-variable-with-no-name)
1515

1616
An unnamed variable declaration creates a temporary object that is discarded at the end of the statement. Such temporary objects with nontrivial behavior may point to either inefficient code that allocates and immediately throws away resources or to the code that unintentionally ignores nonprimitive data. Sometimes it may also indicate plainly wrong declaration.
1717

@@ -46,4 +46,4 @@ void Foo()
4646
## See also
4747

4848
[C26441](C26441.md)\
49-
[ES.84: Don't (try to) declare a local variable with no name](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-noname)
49+
[ES.84: Don't try to declare a local variable with no name](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es84-dont-try-to-declare-a-local-variable-with-no-name)

docs/code-quality/c26449.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ helpviewer_keywords: ["C26449"]
99

1010
> `gsl::span` or `std::string_view` created from a temporary will be invalid when the temporary is invalidated (gsl.view)
1111
12-
C++ Core Guidelines: [GSL.view: Views](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#SS-views).
12+
C++ Core Guidelines: [GSL.view: Views](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#gslview-views).
1313

1414
Spans and views are convenient and lightweight types that allow you to reference memory buffers. But they must be used carefully: while their interface looks similar to standard containers, their behavior is more like the behavior of pointers and references. They don't own data and must never be constructed from temporary buffers. This check focuses on cases where source data is temporary, while a span or view isn't. This rule can help to avoid subtle but dangerous mistakes made when legacy code gets modernized and adopts spans or views. There's another check that handles a slightly different scenario involving span references: [C26445 NO_SPAN_REF](c26445.md).
1515

docs/code-quality/c26450.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ long long multiply()
4747
[C26452](c26452.md)\
4848
[C26453](c26453.md)\
4949
[C26454](c26454.md)\
50-
[ES.103: Don't overflow](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-overflow)
50+
[ES.103: Don't overflow](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es103-dont-overflow)

docs/code-quality/c26452.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ unsigned long long combine(unsigned lo, unsigned hi)
4141
[C26451](c26451.md)\
4242
[C26453](c26453.md)\
4343
[C26454](c26454.md)\
44-
[ES.101: Use unsigned types for bit manipulation](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-unsigned)\
45-
[ES.102: Use signed types for arithmetic](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-signed)
44+
[ES.101: Use unsigned types for bit manipulation](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es101-use-unsigned-types-for-bit-manipulation)\
45+
[ES.102: Use signed types for arithmetic](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es102-use-signed-types-for-arithmetic)

0 commit comments

Comments
 (0)