Moderators: david ward, misra cpp
- Posts: 3
- Joined: Fri May 27, 2011 10:19 am
- Company: Falcon One Ltd
Is rule 7-5-3 really relevant?
It says that something like
is not compliant.
But surely all C++ developers on the planet would expect x to be modified here after calling f:
So why returning x directly would be an issue? I guess there is probably something I am not seeing here!
Thanks for any clarification!
- Posts: 161
- Joined: Mon Jun 02, 2008 1:55 pm
- Company: MISRA
7-5-3 is important for const references where a copy may be created. Non-conforming compilers in use when MISRA C++:2008 was developed also had the same behaviour for non-const objects.
We will review this guideline in the next version of MISRA C++.
Posted by and on behalf of
the MISRA C++ Working Group