Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 value, but the resulting behavior is undefined. According to ISO/IEC 9899:1999, Section 6.7.3 "Type Qualifiers":

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.

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

CERT C++ Secure Coding Standard: EXP32-CPP. Do not access a volatile object through a non-volatile reference

Bibliography

unmigrated-wiki-markup

\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.7.3, "Type qualifiers," and Section 6.5.16.1, "Simple assignment" \[[

ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] TR 24772 "HFC Pointer casting and pointer type changes" and "IHN Type system" \[[MISRA 2004|AA. Bibliography#MISRA 04]\] Rule

MISRA Rule 11.5

Bibliography

...

EXP31-C. Avoid side effects in assertions      03. Expressions (EXP)      EXP33-C. Do not reference uninitialized memory