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 |
[C++ only]
A member function f() is not declared static, and all of the following are true.
See also Member Function Could be const.
| Class Name | Member Function Could Be static | ||||||
|---|---|---|---|---|---|---|---|
| Significance | style | ||||||
| Mnemonic | LANG.TYPE.MFCBSTATIC | ||||||
| Categories |
|
||||||
| 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="Member Function Could Be static" |
class MyClass {
public:
MyClass(void){ myint=5;my_static_int=10; }
int literal(int i){ // 'Member Function Could Be static' warning issued here
return 5;
}
int cbconst(int i){ // ok: accesses non-static data member myint
// ('Member Function Could be const' warning will be issued if enabled)
my_static_int += 2;
return myint;
}
int cbstatic(int i){ // 'Member Function Could Be static' warning issued here
my_static_int += i;
return my_static_int;
}
static int marked_static(int i){ // ok: declared static
my_static_int += i;
return my_static_int;
}
int cbstatic_uncalled(int i){ // inline and not called, so no warning of this class is issued
my_static_int += i;
return my_static_int;
}
int noninline_cbstatic(int i);
private:
int myint;
static int my_static_int;
};
int MyClass::noninline_cbstatic(int i){ // 'Member Function Could Be static' warning issued here
my_static_int += i;
return my_static_int;
}
int use_MyClass( void ){
MyClass mc;
int i=0;
int rv;
rv = mc.literal(i);
rv = rv + mc.cbconst(0);
rv = rv + mc.cbstatic(i);
rv = rv + mc.marked_static(i);
return rv;
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.