You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -36,15 +36,15 @@ Starting in Visual Studio 2019 version 16.7:
36
36
37
37
1. Select the **CET Shadow Stack Compatible** property.
38
38
39
-
1. In the dropdown control, choose **`Yes (/CETCOMPAT)`** to enable EH continuation metadata, or **`No (/CETCOMPAT:NO)`** to disable it.
39
+
1. In the dropdown control, choose **`Yes (/CETCOMPAT)`** to mark the binary as CET Shadow Stack compatible , or **`No (/CETCOMPAT:NO)`** to mark it as non-compatible.
40
40
41
41
In previous versions of Visual Studio 2019:
42
42
43
43
1. Open the **Property Pages** dialog box for the project. For more information, see [Working with Project Properties](../working-with-project-properties.md).
1. In the **Additional Options** edit control, add *`/CETCOMPAT`* to enable EH continuation metadata, or *`/CETCOMPAT:NO`* to explicitly disable it.
47
+
1. In the **Additional Options** edit control, add *`/CETCOMPAT`* to mark the binary as CET Shadow Stack compatible, or *`/CETCOMPAT:NO`* to explicitly mark it as non-compatible.
@@ -38,6 +38,7 @@ You can use the [comment](../../preprocessor/comment-c-cpp.md) pragma to specify
38
38
|[/ASSEMBLYMODULE](assemblymodule-add-a-msil-module-to-the-assembly.md)|Specifies that a Microsoft intermediate language (MSIL) module should be imported into the assembly.|
39
39
|[/ASSEMBLYRESOURCE](assemblyresource-embed-a-managed-resource.md)|Embeds a managed resource file in an assembly.|
40
40
|[/BASE](base-base-address.md)|Sets a base address for the program.|
41
+
|[/CETCOMPAT](cetcompat.md)|Marks the binary as CET Shadow Stack compatible.|
41
42
|[/CGTHREADS](cgthreads-compiler-threads.md)|Sets number of cl.exe threads to use for optimization and code generation when link-time code generation is specified.|
42
43
|[/CLRIMAGETYPE](clrimagetype-specify-type-of-clr-image.md)|Sets the type (IJW, pure, or safe) of a CLR image.|
43
44
|[/CLRSUPPORTLASTERROR](clrsupportlasterror-preserve-last-error-code-for-pinvoke-calls.md)|Preserves the last error code of functions that are called through the P/Invoke mechanism.|
Copy file name to clipboardExpand all lines: docs/code-quality/c26401.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,40 @@ ms.topic: "conceptual"
5
5
f1_keywords: ["C26401"]
6
6
helpviewer_keywords: ["C26401"]
7
7
ms.assetid: b9d3d398-697a-4a5d-8bfe-9c667dffb90b
8
+
description: CppCoreCheck rule that enforces C++ Core Guidelines I.11
8
9
---
9
10
# C26401 DONT_DELETE_NON_OWNER
10
11
11
12
This check detects places where moving to `owner<T>` can be a good option for the first stage of refactoring. Like C26400 it enforces rules I.11 and R.3, but focuses on the "release" portion of the pointer lifetime. It warns on any call to operator **`delete`** if its target is neither an `owner<T>` nor an implicitly assumed owner. For more information, see [C26400](c26400.md) regarding the **`auto`** declarations. This does include expressions that refer to global variables, formals, and so on.
12
13
13
14
Warnings C26400 and C26401 always occur with [C26409](c26409.md), but they are more appropriate for scenarios where immediate migration to smart pointers is not feasible. In such cases the `owner<T>` concept can be adopted first and C26409 may be temporarily suppressed.
Copy file name to clipboardExpand all lines: docs/code-quality/c26408.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ ms.topic: "conceptual"
5
5
f1_keywords: ["C26408"]
6
6
helpviewer_keywords: ["C26408"]
7
7
ms.assetid: 55b0706f-1107-41c1-8ad0-c9e1e86a3b8c
8
+
description: CppCoreCheck rule that enforces C++ Core Guidelines R.10
8
9
---
9
10
# C26408 NO_MALLOC_FREE
10
11
@@ -15,3 +16,23 @@ This warning flags places where `malloc` or `free` is invoked explicitly in acco
15
16
- To detect malloc() we check if a call invokes a global function with name "malloc" or "std::malloc". The function must return a pointer to **`void`** and accept one parameter of unsigned integral type.
16
17
17
18
- To detect free() we check global functions with names "free" or "std::free" which return no result and accept one parameter, which is a pointer to **`void`**.
Copy file name to clipboardExpand all lines: docs/code-quality/c26436.md
+31-2Lines changed: 31 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,17 +5,46 @@ ms.topic: "conceptual"
5
5
f1_keywords: ["C26436"]
6
6
helpviewer_keywords: ["C26436"]
7
7
ms.assetid: 82d14d5d-5c5d-4e27-bdc8-268f9973a312
8
+
description: CppCoreCheck rule that enforces C++ Core Guidelines C.35
8
9
---
9
10
# C26436 NEED_VIRTUAL_DTOR
10
11
11
12
"The type with a virtual function needs either public virtual or protected nonvirtual destructor."
12
13
13
-
**C++ Core Guidelines**:
14
-
C.35: A base class destructor should be either public and virtual, or protected and nonvirtual
14
+
[**C++ Core Guidelines**: C.35](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c35-a-base-class-destructor-should-be-either-public-and-virtual-or-protected-and-non-virtual): A base class destructor should be either public and virtual, or protected and nonvirtual
15
15
16
16
If a class defines a virtual function it becomes polymorphic, which implies that derived classes can change its behavior including resource management and destruction logic. Because client code may call polymorphic types via pointers to base classes, there is no way a client can explicitly choose which behavior is appropriate without downcasting. To make sure that resources are managed consistently and destruction occurs according to the actual type's rules it is recommended to define a public virtual destructor. If the type hierarchy is designed to disallow client code to destroy objects directly, destructors should be defined as protected non-virtual.
17
17
18
18
## Remarks
19
19
20
20
- The warning shows up on the first virtual function definition of a type (it can be a virtual destructor if it is not public), once per type.
21
21
- Since definition can be placed separately from declaration, it may not always have any of the virtual specifiers. But the warning is still valid – it checks the actual 'virtuality' of a function.
22
+
23
+
## Example
24
+
```cpp
25
+
namespaceno_destructor
26
+
{
27
+
struct base {
28
+
virtual void foo() {} // C26436, see remarks to understand the placement of the warning.
29
+
};
30
+
}
31
+
```
32
+
33
+
The warning does not appear when the base class has either a virtual public destructor or a protected non-virtual destructor.
Copy file name to clipboardExpand all lines: docs/code-quality/c26439.md
+32-2Lines changed: 32 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ ms.topic: "conceptual"
5
5
f1_keywords: ["C26439"]
6
6
helpviewer_keywords: ["C26439"]
7
7
ms.assetid: 9df2a1b0-ea94-4884-9d28-c1522ec33a1b
8
+
description: CppCoreCheck rule that enforces C++ Core Guidelines F.6
8
9
---
9
10
# C26439 SPECIAL_NOEXCEPT
10
11
11
12
"This kind of function may not throw. Declare it 'noexcept'."
12
13
13
-
**C++ Core Guidelines**:
14
-
F.6: If your function may not throw, declare it noexcept
14
+
[**C++ Core Guidelines** F.6](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#f6-if-your-function-may-not-throw-declare-it-noexcept): If your function may not throw, declare it noexcept
15
15
16
16
Some kinds of operations should never cause exceptions. Their implementations should be reliable and should handle possible errors conditions gracefully. They should never use exceptions to indicate failure. This rule flags cases where such operations are not explicitly marked as 'noexcept' which means that they may throw exceptions and cannot convey assumptions about their reliability.
17
17
@@ -25,3 +25,33 @@ Some kinds of operations should never cause exceptions. Their implementations sh
25
25
- Non-standard and outdated specifiers like throw() or declspec(nothrow) are not equivalent to 'noexcept'.
26
26
- Explicit specifiers noexcept(false) and noexcept(true) are respected appropriately.
27
27
- The warning may still appear for operations that are marked as constexpr. This may change in future releases.
28
+
29
+
## Example
30
+
All functions except the destructor will warn because they are missing noexcept.
31
+
```cpp
32
+
structS
33
+
{
34
+
S() {} // C26455, Default constructor may not throw. Declare it 'noexcept'
35
+
~S() {}
36
+
37
+
S(S&& s) {/*impl*/} // C26439, This kind of function may not throw. Declare it 'noexcept' (f.6)
38
+
S& operator=(S&& s) {/*impl*/} // C26439, This kind of function may not throw. Declare it 'noexcept' (f.6)
39
+
40
+
S(const S& s) {/*impl*/} // C26440, This function can be declared 'noexcept'
41
+
S& operator=(const S& s) {/*impl*/} // C26440, This function can be declared 'noexcept'
42
+
};
43
+
```
44
+
With noexcept decorating the same structure, all warnings are removed.
Copy file name to clipboardExpand all lines: docs/code-quality/c26440.md
+32-2Lines changed: 32 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ ms.topic: "conceptual"
5
5
f1_keywords: ["C26440"]
6
6
helpviewer_keywords: ["C26440"]
7
7
ms.assetid: b6d2b188-35cc-4de2-878c-6f97d5a2444a
8
+
description: CppCoreCheck rule that enforces C++ Core Guidelines F.6
8
9
---
9
10
# C26440 DECLARE_NOEXCEPT
10
11
11
12
"Function can be declared 'noexcept'."
12
13
13
-
**C++ Core Guidelines**:
14
-
F.6: If your function may not throw, declare it noexcept
14
+
[**C++ Core Guidelines** F.6](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#f6-if-your-function-may-not-throw-declare-it-noexcept): If your function may not throw, declare it noexcept
15
15
16
16
If code is not supposed to cause any exceptions, it should be marked as such by using the 'noexcept' specifier. This would help to simplify error handling on the client code side, as well as enable compiler to do additional optimizations.
17
17
@@ -25,3 +25,33 @@ If code is not supposed to cause any exceptions, it should be marked as such by
25
25
- Functions marked as constexpr are not supposed to cause exceptions and are not analyzed.
26
26
- The rule also applies to lambda expressions.
27
27
- The logic doesn't consider recursive calls as potentially non-throwing. This may change in the future.
28
+
29
+
## Example
30
+
All functions except the destructor will warn because they are missing noexcept.
31
+
```cpp
32
+
structS
33
+
{
34
+
S() {} // C26455, Default constructor may not throw. Declare it 'noexcept'
35
+
~S() {}
36
+
37
+
S(S&& s) {/*impl*/} // C26439, This kind of function may not throw. Declare it 'noexcept' (f.6)
38
+
S& operator=(S&& s) {/*impl*/} // C26439, This kind of function may not throw. Declare it 'noexcept' (f.6)
39
+
40
+
S(const S& s) {/*impl*/} // C26440, This function can be declared 'noexcept'
41
+
S& operator=(const S& s) {/*impl*/} // C26440, This function can be declared 'noexcept'
42
+
};
43
+
```
44
+
With noexcept decorating the same structure, all warnings are removed.
Copy file name to clipboardExpand all lines: docs/code-quality/c26482.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,21 @@ ms.date: 03/22/2018
4
4
ms.topic: reference
5
5
f1_keywords: ["C26482"]
6
6
helpviewer_keywords: ["C26482"]
7
+
description: CppCoreCheck rule that enforces C++ Core Guidelines Bounds.2
7
8
---
8
9
# C26482 NO_DYNAMIC_ARRAY_INDEXING
9
10
10
-
Only index into arrays using constant expressions. See [C++ Core Guidelines Bounds.2](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-bounds)
11
+
Only index into arrays using constant expressions.
Copy file name to clipboardExpand all lines: docs/code-quality/c26492.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,20 @@ ms.date: 03/22/2018
4
4
ms.topic: reference
5
5
f1_keywords: ["C26492"]
6
6
helpviewer_keywords: ["C26492"]
7
+
description: CppCoreCheck rule that enforces C++ Core Guidelines Type.3
7
8
---
8
9
# C26492 NO_CONST_CAST
9
10
10
-
Don't use `const_cast` to cast away `const`. See [C++ Core Guidelines Type.3](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-type).
0 commit comments