An object that has volatile-qualified type may be modified in ways unknown to the implementation or have other unknown side effects. It is possible to reference a volatile object by using a non-volatile nonvolatile value, but the resulting behavior is undefined. The C standardStandard, Section 6.7.3 [ISO/IEC 9899:2011], states:
If an attempt is made to refer to an object defined with a volatile-qualified type through use of an lvalue with non-volatile-qualified type, the behavior is undefined.
(See also undefined behavior 65 of in Appendix J of the C Standard.)
Noncompliant Code Example
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
GCC |
|
| Can detect violations of this rule when the | ||||||
Compass/ROSE |
|
|
| ||||||
| 344 S | Fully implemented. | |||||||
PRQA QA-C |
| 0312 | Fully implemented. |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
...
EXP32-CPP. Do not access a volatile object through a non-volatile reference | |
---|---|
ISO/IEC TR 24772 | Pointer casting and pointer type changes [HFC] and Type system [IHN] |
MISRA-C | Rule 11.5 |
Bibliography
...
] | Section 6.7.3, "Type |
---|
...
Qualifiers," and Section 6.5.16.1, "Simple |
---|
...
ISO/IEC TR 24772 "HFC Pointer casting and pointer type changes" and "IHN Type system"
MISRA Rule 11.5
...
Assignment" |
---|