rspec/rules/S6200/cfamily/rule.adoc
2023-09-20 14:18:08 +02:00

22 lines
928 B
Plaintext

== Why is this an issue?
``++volatile++`` can be used to qualify many objects in C and {cpp}, but only a few of the possible places have a well-defined meaning (global variables and local variables, for instance).
There is no well-defined meaning to the use of volatile to qualify a function return type or a function parameter.
Furthermore, for structured bindings, the volatile qualifier appertains to the decomposed object, which cannot be referred to.
Since {cpp}20, these uses are deprecated, but even before you should not use volatile in those places.
This rule raises an issue for a volatile qualified function return type, function parameter, and structured binding (available in {cpp} since {cpp}17).
=== Noncompliant code example
[source,cpp]
----
int volatile f(int volatile i); // Noncompliant, both for the return type and the parameter
void g() {
auto volatile [a, b] = getPair(); // Noncompliant
}
----