Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A20-8-2 / A20-8-3 - Is returning a non-owning pointer always a violation?
#5
This code should not be reported as a violation of A20-8-2/A20-8-3, as these are about the explicit use of unique_ptr/shared_ptr, and not requiring their use in situations such as in the above example.

However, the code does violate A9-3-1 Member functions shall not return non-const “raw” pointers or references to private or protected data owned by the class.

We agree with the poster that replied “…concentrate on inline C++ wrappers around the POSIX stuff so that you minimize the number of places where you have to justify the violations.  A lot will be gained with proper layered system design.”
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread
RE: A20-8-2 / A20-8-3 - Is returning a non-owning pointer always a violation? - by misra cpp - 27-10-2023, 03:45 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)