A20-8-6 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: AUTOSAR C++:2014 rules (https://forum.misra.org.uk/forumdisplay.php?fid=185) +--- Thread: A20-8-6 (/showthread.php?tid=1596) |
A20-8-6 - martin.m.dowie - 12-01-2022 What is the preferred method of assigning to a local member data of type std::shared_ptr<T>? Given the code below, are the lines indicated as A20-8-6 non-compliant really so and why? We can understand C2 (types match exactly). We can understand C4 (types match exactly and the member data is of std::shared_ptr<T>&. The class C1 we believe is non-compliant but we can't justify ourselves of the reason why. Is the rule trying to enforce 3 e) from GoTW #91 (https://herbsutter.com/2013/06/05/gotw-91-solution-smart-pointer-parameters/)? Code: struct S {}; RE: A20-8-6 - misra cpp - 26-01-2022 In the examples, you are not creating new owned objects. The owned objects were created earlier and are already owned by the parameters to these functions. Therefore, this rule does not apply to these examples. |