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
description: "Describes the Microsoft C/C++ code analysis warning C6390, its causes, and how to address it."
4
+
ms.date: 06/17/2022
5
+
f1_keywords: ["C6390"]
6
+
helpviewer_keywords: ["C6390"]
7
+
---
8
+
9
+
# C6390: NO_NULLCHECK_FOR_THIS
10
+
11
+
According to the C++ standard, the value of `this` is never null; some compilers will optimize null checks for `this` out. While MSVC is not doing such optimizations, code relying on null-valued `this` can trigger unexpected behavior when compiled with other compilers. This warning helps detect these portability problems.
12
+
13
+
## Example
14
+
15
+
```cpp
16
+
structX
17
+
{
18
+
void m()
19
+
{
20
+
if(!this) // Warning: According to the C++ standard, the value of 'this' is never null; some compilers will optimize this check out
21
+
return;
22
+
}
23
+
};
24
+
```
25
+
26
+
To solve this problem, rewrite the code to never call non-static member functions on null pointers.
Copy file name to clipboardExpand all lines: docs/data/oledb/user-record.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
1
---
2
2
description: "Learn more about: User Record"
3
3
title: "User Record"
4
-
ms.date: "05/09/2019"
4
+
ms.date: 06/21/2022
5
5
helpviewer_keywords: ["records, user", "OLE DB providers, user record", "user records", "user records, described", "rowsets, user record"]
6
6
ms.assetid: 9c0d2864-2738-4f62-a750-1016d9c3523f
7
+
ms.custom: devdivchpfy22
7
8
---
9
+
8
10
# User Record
9
11
10
12
> [!NOTE]
@@ -53,7 +55,7 @@ The PROVIDER_COLUMN_MAP macros aid in creating a `GetColumnInfo` function:
53
55
54
56
- END_PROVIDER_COLUMN_MAP closes the array and the function. It also places the array element count into the *pcCols* parameter.
55
57
56
-
When a user record is created at run time, `GetColumnInfo` uses the *pThis* parameter to receive a pointer to a rowset or command instance. Commands and rowsets must support the `IColumnsInfo` interface, so column information can be taken from this pointer.
58
+
When a user record is created at run time, `GetColumnInfo` uses the *`pThis`* parameter to receive a pointer to a rowset or command instance. Commands and rowsets must support the `IColumnsInfo` interface, so column information can be taken from this pointer.
57
59
58
60
`CommandClass` and `RowsetClass` are the command and rowset that use the user record.
@@ -21,11 +23,11 @@ class scoped_allocator_adaptor;
21
23
22
24
The class template encapsulates a nest of one or more allocators. Each such class has an outermost allocator of type `outer_allocator_type`, a synonym for `Outer`, which is a public base of the `scoped_allocator_adaptor` object. `Outer` is used to allocate memory to be used by a container. You can obtain a reference to this allocator base object by calling `outer_allocator`.
23
25
24
-
The remainder of the nest has type `inner_allocator_type`. An inner allocator is used to allocate memory for elements within a container. You can obtain a reference to the stored object of this type by calling `inner_allocator`. If `Inner...` is not empty, `inner_allocator_type` has type `scoped_allocator_adaptor<Inner...>`, and `inner_allocator` designates a member object. Otherwise, `inner_allocator_type` has type `scoped_allocator_adaptor<Outer>`, and `inner_allocator` designates the entire object.
26
+
The remainder of the nest has type `inner_allocator_type`. An inner allocator is used to allocate memory for elements within a container. You can obtain a reference to the stored object of this type by calling `inner_allocator`. If `Inner...` isn't empty, `inner_allocator_type` has type `scoped_allocator_adaptor<Inner...>`, and `inner_allocator` designates a member object. Otherwise, `inner_allocator_type` has type `scoped_allocator_adaptor<Outer>`, and `inner_allocator` designates the entire object.
25
27
26
28
The nest behaves as if it has arbitrary depth, replicating its innermost encapsulated allocator as needed.
27
29
28
-
Several concepts that are not a part of the visible interface aid in describing the behavior of this class template. An *outermost allocator* mediates all calls to the construct and destroy methods. It is effectively defined by the recursive function `OUTERMOST(X)`, where `OUTERMOST(X)` is one of the following.
30
+
Several concepts that aren't a part of the visible interface aid in describing the behavior of this class template. An *outermost allocator* mediates all calls to the construct and destroy methods. It's effectively defined by the recursive function `OUTERMOST(X)`, where `OUTERMOST(X)` is one of the following.
29
31
30
32
- If `X.outer_allocator()` is well formed, then `OUTERMOST(X)` is `OUTERMOST(X.outer_allocator())`.
Describes an *asynchronous return object*. In contrast with a [future](../standard-library/future-class.md) object, an *asynchronous provider* can be associated with any number of `shared_future` objects.
@@ -19,9 +21,9 @@ class shared_future;
19
21
20
22
## Remarks
21
23
22
-
Do not call any methods other than `valid`, `operator=`, and the destructor on a `shared_future` object that's *empty*.
24
+
Don't call any methods other than `valid`, `operator=`, and the destructor on a `shared_future` object that's *empty*.
23
25
24
-
`shared_future` objects are not synchronized. Calling methods on the same object from multiple threads introduces a data race that has unpredictable results.
26
+
`shared_future` objects aren't synchronized. Calling methods on the same object from multiple threads introduces a data race that has unpredictable results.
25
27
26
28
## Members
27
29
@@ -36,7 +38,7 @@ Do not call any methods other than `valid`, `operator=`, and the destructor on a
36
38
|Name|Description|
37
39
|----------|-----------------|
38
40
|[get](#get)|Retrieves the result that's stored in the *associated asynchronous state*.|
39
-
|[valid](#valid)|Specifies whether the object is not empty.|
41
+
|[valid](#valid)|Specifies whether the object isn't empty.|
40
42
|[wait](#wait)|Blocks the current thread until the associated asynchronous state is ready.|
41
43
|[wait_for](#wait_for)|Blocks until the associated asynchronous state is ready or until the specified time has elapsed.|
42
44
|[wait_until](#wait_until)|Blocks until the associated asynchronous state is ready or until a specified point in time.|
Wraps a reference-counted smart pointer around a dynamically allocated object.
@@ -25,7 +27,7 @@ A `shared_ptr` stops owning a resource when it's reassigned or reset.
25
27
26
28
The template argument `T` might be an incomplete type except as noted for certain member functions.
27
29
28
-
When a `shared_ptr<T>` object is constructed from a resource pointer of type `G*` or from a `shared_ptr<G>`, the pointer type `G*` must be convertible to `T*`. If it's not convertible, the code will not compile. For example:
30
+
When a `shared_ptr<T>` object is constructed from a resource pointer of type `G*` or from a `shared_ptr<G>`, the pointer type `G*` must be convertible to `T*`. If it's not convertible, the code won't compile. For example:
29
31
30
32
```cpp
31
33
#include<memory>
@@ -63,29 +65,29 @@ The `shared_ptr` objects that own a resource share a control block. The control
63
65
64
66
- the custom allocator for the control block if it has one.
65
67
66
-
A `shared_ptr` object that is initialized by using a null pointer has a control block and is not empty. After a `shared_ptr` object releases a resource, it no longer owns that resource. After a `weak_ptr` object releases a resource, it no longer points to that resource.
68
+
A `shared_ptr` object that is initialized by using a null pointer has a control block and isn't empty. After a `shared_ptr` object releases a resource, it no longer owns that resource. After a `weak_ptr` object releases a resource, it no longer points to that resource.
67
69
68
70
When the number of `shared_ptr` objects that own a resource becomes zero, the resource is freed, either by deleting it or by passing its address to a deleter, depending on how ownership of the resource was originally created. When the number of `shared_ptr` objects that own a resource is zero, and the number of `weak_ptr` objects that point to that resource is zero, the control block is freed, using the custom allocator for the control block if it has one.
69
71
70
-
An empty `shared_ptr` object does not own any resources and has no control block.
72
+
An empty `shared_ptr` object doesn't own any resources and has no control block.
71
73
72
74
A deleter is a function object that has a member function `operator()`. Its type must be copy constructible, and its copy constructor and destructor must not throw exceptions. It accepts one parameter, the object to be deleted.
73
75
74
76
Some functions take an argument list that defines properties of the resulting `shared_ptr<T>` or `weak_ptr<T>` object. You can specify such an argument list in several ways:
75
77
76
-
no arguments -- the resulting object is an empty `shared_ptr` object or an empty `weak_ptr` object.
78
+
no arguments: The resulting object is an empty `shared_ptr` object or an empty `weak_ptr` object.
77
79
78
-
`ptr` -- a pointer of type `Other*` to the resource to be managed. `T` must be a complete type. If the function fails (because the control block can't be allocated), it evaluates the expression `delete ptr`.
80
+
`ptr`: A pointer of type `Other*` to the resource to be managed. `T` must be a complete type. If the function fails (because the control block can't be allocated), it evaluates the expression `delete ptr`.
79
81
80
-
`ptr, deleter` -- a pointer of type `Other*` to the resource to be managed and a deleter for that resource. If the function fails (because the control block can't be allocated), it calls `deleter(ptr)`, which must be well-defined.
82
+
`ptr, deleter`: A pointer of type `Other*` to the resource to be managed and a deleter for that resource. If the function fails (because the control block can't be allocated), it calls `deleter(ptr)`, which must be well-defined.
81
83
82
-
`ptr, deleter, alloc` -- a pointer of type `Other*` to the resource to be managed, a deleter for that resource, and an allocator to manage any storage that must be allocated and freed. If the function fails (because the control block can't be allocated), it calls `deleter(ptr)`, which must be well-defined.
84
+
`ptr, deleter, alloc`: A pointer of type `Other*` to the resource to be managed, a deleter for that resource, and an allocator to manage any storage that must be allocated and freed. If the function fails (because the control block can't be allocated), it calls `deleter(ptr)`, which must be well-defined.
83
85
84
-
`sp` -- a `shared_ptr<Other>` object that owns the resource to be managed.
86
+
`sp`: A `shared_ptr<Other>` object that owns the resource to be managed.
85
87
86
-
`wp` -- a `weak_ptr<Other>` object that points to the resource to be managed.
88
+
`wp`: A `weak_ptr<Other>` object that points to the resource to be managed.
87
89
88
-
`ap` -- an `auto_ptr<Other>` object that holds a pointer to the resource to be managed. If the function succeeds, it calls `ap.release()`; otherwise it leaves `ap` unchanged.
90
+
`ap`: An `auto_ptr<Other>` object that holds a pointer to the resource to be managed. If the function succeeds, it calls `ap.release()`; otherwise it leaves `ap` unchanged.
89
91
90
92
In all cases, the pointer type `Other*` must be convertible to `T*`.
The member function returns the address of the owned resource. If the object does not own a resource, it returns 0.
167
+
The member function returns the address of the owned resource. If the object doesn't own a resource, it returns 0.
166
168
167
169
### Example
168
170
@@ -705,7 +707,7 @@ The shared pointer to swap with.
705
707
706
708
### Remarks
707
709
708
-
The member function leaves the resource originally owned by **`*this`** subsequently owned by *`sp`*, and the resource originally owned by *`sp`* subsequently owned by **`*this`**. The function does not change the reference counts for the two resources and it does not throw any exceptions.
710
+
The member function leaves the resource originally owned by **`*this`** subsequently owned by *`sp`*, and the resource originally owned by *`sp`* subsequently owned by **`*this`**. The function doesn't change the reference counts for the two resources and it doesn't throw any exceptions.
@@ -27,7 +29,7 @@ The iterator type for submatches.
27
29
28
30
The class template describes an object that designates a sequence of characters that matched a capture group in a call to [regex_match](../standard-library/regex-functions.md#regex_match) or to [regex_search](../standard-library/regex-functions.md#regex_search). Objects of type [match_results Class](../standard-library/match-results-class.md) hold an array of these objects, one for each capture group in the regular expression that was used in the search.
29
31
30
-
If the capture group was not matched the object's data member `matched` holds false, and the two iterators `first` and `second` (inherited from the base `std::pair`) are equal. If the capture group was matched, `matched` holds true, the iterator `first` points to the first character in the target sequence that matched the capture group, and the iterator `second` points one position past the last character in the target sequence that matched the capture group. Note that for a zero-length match the member `matched` holds true, the two iterators will be equal, and both will point to the position of the match.
32
+
If the capture group wasn't matched the object's data member `matched` holds false, and the two iterators `first` and `second` (inherited from the base `std::pair`) are equal. If the capture group was matched, `matched` holds true, the iterator `first` points to the first character in the target sequence that matched the capture group, and the iterator `second` points one position past the last character in the target sequence that matched the capture group. For a zero-length match, the member `matched` holds true, the two iterators will be equal, and both will point to the position of the match.
31
33
32
34
A zero-length match can occur when a capture group consists solely of an assertion, or of a repetition that allows zero repeats. For example:
0 commit comments