Constexpr or const specifiers shall be used for immutable data declaration
Constexpr or const specifiers shall be used for immutable data declaration.
Declaring a variable const or constexpr reduces
the chances that you modify the variable by accident. In addition, compilers can perform
various optimizations on const and constexpr variables
to improve run-time performance.
The checker flags function parameters or local variables that are not const-qualified but never modified in the function body. Function parameters of integer, float, enum and boolean types are not flagged.
If a variable is passed to another function by reference or pointers, the checker assumes that the variable can be modified. These variables are not flagged.
If you expect a rule violation but do not see it, refer to the documentation for Polyspace® Bug Finder™ or Polyspace Bug Finder Server™.
| Group: Declaration |
| Category: Required, Automated |