...
Adjacent bit-fields may be stored in a single memory location. Consequently, modifying adjacent bit-fields in different threads is undefined behavior 5, as shown in this noncompliant code example:
...
Although the race window is narrow, an assignment or an expression can evaluate improperly because of misinterpreted data resulting in a corrupted running state or unintended information disclosure.
Rule | Severity | Likelihood | Detectable | Remediation CostRepairable | Priority | Level |
|---|---|---|---|---|---|---|
CON32-C | Medium | Probable | No | MediumNo | P8P4 | L2L3 |
Automated Detection
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| read_data_race write_data_race | Supported by sound analysis (data race alarm) | ||||||
| Axivion Bauhaus Suite |
| CertC-CON32 | |||||||
| CodeSonar |
| CONCURRENCY.DATARACE CONCURRENCY.MAA | Data race Multiple Accesses of Atomic | ||||||
| Coverity |
| MISSING_LOCK | Partially implemented | ||||||
| Cppcheck Premium |
| premium-cert-con32-c | |||||||
| Helix QAC |
| C1774, C1775 | |||||||
| Parasoft C/C++test |
| CERT_C-CON32-a | Use locks to prevent race conditions when modifying bit fields | ||||||
| PC-lint Plus |
| 457 | Partially supported: access is detected at the object level (not at the field level) | ||||||
| Polyspace Bug Finder |
| CERT C: Rule CON32-C | Checks for data race (rule fully covered) |
...