Variable can be modified between accesses
This defect occurs
when C atomic types or C++
std::atomic class variables appear twice in an expression and
there are:
Two atomic read operations on the variable.
An atomic read and a distinct atomic write operation on the variable.
The C standard defines certain operations on atomic variables that are thread safe and do not cause data race conditions. Unlike individual operations, a pair of operations on the same atomic variable in an expression is not thread safe.
A thread can modify the atomic variable between the pair of atomic operations, which can result in a data race condition.
Do not reference an atomic variable twice in the same expression.
| Group: Concurrency |
| Language: C | C++ |
| Default: On for handwritten code, off for generated code |
Command-Line Syntax:
ATOMIC_VAR_ACCESS_TWICE |
| Impact: Medium |
Atomic load and store
sequence not atomic | Data race | Data race including atomic operations | Find defects (-checkers)