JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
A variable is not modified, but is not declared with a const or (C++ only) constexpr specifier.
See also Pointed-to Type Could Be const.
| Class Name | Variable Could Be const | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | style | ||||||||||||
| Mnemonic | LANG.TYPE.VCBC | ||||||||||||
| Categories |
|
||||||||||||
| Availability | Available for C and C++. |
||||||||||||
| Enabling | Checks for this warning class are
disabled by default. To enable them, add the following WARNING_FILTER
rule to the project configuration file.
WARNING_FILTER += allow class="Variable Could Be const" |
int use_params(int * p1, // ok: p1 is modified int * p2, // 'Variable Could Be const' warning issued here int * const p3){ // ok: unmodified parameter marked const if (!p1 || !p2 || !p3) {return -1;} p1 = p2; // p1 is modified here *p2 = 2; // *p2 is modified here, but p2 is not modified return *p1 + *p2 + *p3; } constexpr int five(void) {return 5;} int use_locals(const int k){ // ok: unmodified parameter marked const int a = five(); // 'Variable Could Be const' warning issued here const int b = five(); // ok: unmodified local marked const constexpr int c = five(); // ok: unmodified local marked constexpr int d = five(); // ok: local modified on some paths if (k){ d++; } return a + b + c + d; }
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.