Skip to content

Commit 8581294

Browse files
Updated C28112
Updated to the new format, added more information
1 parent da0065c commit 8581294

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

docs/code-quality/c28112.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
---
22
description: "Learn more about: C28112"
33
title: C28112
4-
ms.date: 11/04/2016
4+
ms.date: 08/25/2022
55
ms.topic: reference
6-
f1_keywords: ["C28112"]
6+
f1_keywords: ["C28112", "INTERLOCKED_ACCESS", "__WARNING_INTERLOCKED_ACCESS"]
77
helpviewer_keywords: ["C28112"]
88
ms.assetid: 2720a5dc-84e9-4f78-a8c7-a320c9f9216b
99
---
10-
# C28112
10+
# Warning C28112
1111

12-
> warning C28112: A variable which is accessed via an Interlocked function must always be accessed via an Interlocked function
12+
> A variable ('\**parameter-name*') which is accessed via an Interlocked function must always be accessed via an Interlocked function. See line '\**line-number*': It is not always safe to access a variable which is accessed via the Interlocked\* family of functions in any other way.
1313
14-
See line *[number]*: It is not always safe to access a variable which is accessed via the Interlocked\* family of functions in any other way.
14+
A variable that is accessed by using the Interlocked executive support routines, such as InterlockedCompareExchangeAcquire, is later accessed by using a different function.
1515

16-
A variable that is accessed by using the Interlocked executive support routines, such as InterlockedCompareExchangeAcquire, is later accessed by using a different function. Although certain ordinary assignments, accesses, and comparisons to variables that are used by the Interlocked\* routines can be safely accessed by using a different function, the risk is great enough to justify examining each instance.
16+
## Remarks
17+
18+
`InterlockedXxx` functions are intended to provide atomic operations, but are only atomic with respect to other `InterlockedXxx` functions. Although certain ordinary assignments, accesses, and comparisons to variables that are used by the Interlocked\* routines can be safely accessed by using a different function, the risk is great enough to justify examining each instance.
19+
20+
Code analysis name: INTERLOCKED_ACCESS
1721

1822
## Example
1923

20-
The following code example generates this warning:
24+
The following code generates this warning:
2125

2226
```cpp
23-
inter_var --;
24-
...
27+
inter_var--;
28+
//code
2529
InterlockedIncrement(&inter_var);
2630
```
2731
28-
The following code example avoids this warning:
32+
The following code corrects this warning by strictly accessing `inter_var` through `InterlockedXxx` functions:
2933
3034
```cpp
3135
InterlockedDecrement(&inter_var);
32-
...
36+
//code
3337
InterlockedIncrement(&inter_var);
3438
```

0 commit comments

Comments
 (0)