C28112
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at C28112.
warning C28112: A variable which is accessed via an Interlocked function must always be accessed via an Interlocked function
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.
A variable that is accessed by using the Interlocked executive support routines, such as InterlockedCompareExchangeAcquire, is later accessed by using a different method.Although certain ordinary assignments, accesses, and comparisons to variables that are used by the Interlocked* routines can be safely accessed by using a different method, the risk is great enough to justify examining each instance.
The following code example generates this warning:
inter_var --; ... InterlockedIncrement(&inter_var);
The following code example avoids this warning:
InterlockedDecrement(&inter_var); ... InterlockedIncrement(&inter_var);