You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CppCoreCheck rule that enforces C++ Core Guidelines con.3
C26461 USE_CONST_POINTER_ARGUMENTS:
The pointer argument '%argument%' for function '%function%' can be marked as a pointer to const (con.3).
A function with a T* argument has the potential to modify the value of the object. If that is not the intent of the function, it is better to make the pointer a const T* instead.
structMyStruct
{
voidMemberFn1() const;
voidMemberFn2();
};
voidFunction1_Helper(const MyStruct* myStruct);
voidFunction1(MyStruct* myStruct) // C26461, neither of the operations on myStruct would modify the pointer's value.
{
if (!myStruct)
return;
myStruct->MemberFn1(); // The member function is constFunction1_Helper(myStruct); // Function1_Helper takes a const
}
voidFunction2(MyStruct* myStruct)
{
if (!myStruct)
return;
myStruct->MemberFn2(); // The member function is non-const, so no C26461 will be issued
}