MISRAC++2008-9-3-1 (C++ only)
In this section:
Synopsis
(Required) const member functions shall not return non-const pointers or references to class-data.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
A member function qualified as const returns a pointer member variable. This check is identical to CONST-member-ret.
Coding standards
This check does not correspond to any coding standard rules.
Code examples
The following code example fails the check and will give a warning:
class C{
int* foo() const {
return p;
}
int* p;
};
The following code example passes the check and will not give a warning about this issue:
class C{
int* foo() {
return p;
}
int* p;
};