Closed
Description
Affected rules
M7-5-1
Rule 7–5–1
A function shall not return a reference or a pointer to
an automatic variable (including parameters), defined
within the function
Description
When a function returns a reference to a class member, this class member is wrongly considered as an automatic variable.
Example
class M7_5_1 {
private:
/// Variable to be referenced
std::uint32_t val_;
public:
/// Triggers M7_5_1
std::uint32_t& M7_5_1() noexcept {
return val_;
}
}