The following code yields false positive in the upstream cppcheck:
#include <iostream> struct ostream_holder { explicit ostream_holder(std::ostream& os) : m_os(os) {} ostream_holder(const ostream_holder&) = default; std::ostream& m_os; }; template <typename T> std::ostream& operator<<(ostream_holder os_holder, const T& value) { os_holder << value; return os_holder.m_os; }
The returned error:
example.cpp:14:21: error: Reference to local variable returned. [returnReference] return os_holder.m_os;
Even though this code is valid, and the "m_os" is not a local reference.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/13373
thanks!
Log in to post a comment.
The following code yields false positive in the upstream cppcheck:
The returned error:
Even though this code is valid, and the "m_os" is not a local reference.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/13373
thanks!