C and C++


LANG.TYPE.IVD : Inappropriate Volatile Declaration

Summary

A variable, parameter, function return type, or member function is declared as volatile.

Properties

Class Name Inappropriate Volatile Declaration
Significance style
Mnemonic LANG.TYPE.IVD
Categories
AUTOSARC++14 AUTOSARC++14:A2-11-1 Volatile keyword shall not be used.
MisraC++2023 MisraC++2023:10.1.2 Volatile qualification shall be used appropriately
CERT-C CERT-C:CON02-C Do not use volatile as a synchronization primitive
JSF++ JSF++:205 The volatile keyword shall not be used unless directly interfacing with hardware.
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Inappropriate Volatile Declaration"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

typedef int volatile vint;

void lang_type_ivd(volatile int i, /* 'Inappropriate Volatile Declaration' warning issued here */
                   vint vi) {      /* 'Inappropriate Volatile Declaration' warning issued here */
    volatile int x;                /* 'Inappropriate Volatile Declaration' warning issued here */
    int * volatile vpi;            /* 'Inappropriate Volatile Declaration' warning issued here */
    volatile int *pvi;                     /* ok: pvi is a nonvolatile pointer to volatile int */
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.