AutosarC++18_10-A2.11.1

Volatile keyword shall not be used

Required inputs: IR

Rationale

The volatile keyword disables compiler optimizations for a particular variable or object’s value in case those values may change in ways not specified by the language (e.g.

object representing a hardware register). It is error prone and often misused by developers, as they expect this is equal to variable or object’s value being atomic.

Note: The main intention of this rule is to eliminate incorrect usages of volatile keyword and force developers to precisely document each usage of volatile keyword.

See Also
  • JSF December 2005 [8]: AV Rule 205: The volatile keyword shall not be used unless directly interfacing with hardware.
  • HIC++ v4.0 [9]: 18.2.3: Do not share volatile data between threads.
  • C++ Core Guidelines [11]: CP.8: Don’t try to use volatile for synchronization.
  • C++ Core Guidelines [11]: CP.200: Use volatile only to talk to non-C++ memory.

Possible Messages

Key

Text

Severity

Disabled

volatile_qualifier

The volatile type qualifier shall not be used

None

False

Options