10-07-2017, 10:47 AM
The non-const get_p is your example is compliant with 9-3-2, even if it is circumventing the aim of the rule.
The rule was drafted to prevent external functions directly modifying the contents of classes. In this case get_p is returning the value of p, not a handle that allows p to be modified. The fact that this allows arr to be modified is beyond the scope of the rule
The rule was drafted to prevent external functions directly modifying the contents of classes. In this case get_p is returning the value of p, not a handle that allows p to be modified. The fact that this allows arr to be modified is beyond the scope of the rule
Posted by and on behalf of
the MISRA C++ Working Group
the MISRA C++ Working Group