Rule M7-5-2 (required, implementation, non-automated)

The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist. See MISRA C++ 2008 [7] Note: C++ specifies that binding a temporary object (e.g. automatic variable returned from a function) to a reference to const prolongs the lifetime of the temporary to the lifetime of the reference. Note: Rule 7-5-2 concerns C++11 smart pointers, i.e. std::unique_ptr, std::shared_ptr and std::weak_ptr, too.


## See also
C++ Core Guidelines [11]: F.45: Don’t return a T&&.