Hi,
for the code
class Foo { std::unique_ptr<Bar> m_Child; }; void Foo::foobar() { barfoo(std::move(m_Child)); m_Child.reset(new Bar()); }
cppcheck head outputs:
./cppcheck --enable=all --inconclusive /home/user/Desktop/foo.cpp Checking /home/user/Desktop/foo.cpp ... /home/user/Desktop/foo.cpp:8:7: warning: inconclusive: Access of moved variable 'm_Child'. [accessMoved] m_Child.reset(new Bar()); ^ /home/user/Desktop/foo.cpp:7:14: note: Calling std::move(m_Child) barfoo(std::move(m_Child)); ^ /home/user/Desktop/foo.cpp:8:7: note: Access of moved variable 'm_Child'. m_Child.reset(new Bar()); ^
reset() should be allowed after move() though?
Best regards, Martin
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11325
Log in to post a comment.
Hi,
for the code
cppcheck head outputs:
reset() should be allowed after move() though?
Best regards,
Martin
Last edit: Martin 2022-09-20
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11325