cppcheck highlights last two lines with error Using reference to dangling temporary.CppCheck(danglingTempReference).
Note that if I change the code line from auto& headerbuf = _queue.emplace(); to simply auto headerbuf = _queue.emplace(); (i.e. type instead of type reference), cppcheck stops flagging, but it's incorrect b/c now it is writing to a copy of memory, rather than into queue's entry's memory space.
Seems that cppcheck fails to recognize that std::tuple<...>& that's returned from std::queue::emplace() is not actually a temporary, but rather a reference to internal member space.
Sample code snippet
cppcheck highlights last two lines with error
Using reference to dangling temporary.CppCheck(danglingTempReference)
.Note that if I change the code line from
auto& headerbuf = _queue.emplace();
to simplyauto headerbuf = _queue.emplace();
(i.e. type instead of type reference), cppcheck stops flagging, but it's incorrect b/c now it is writing to a copy of memory, rather than into queue's entry's memory space.Seems that cppcheck fails to recognize that
std::tuple<...>&
that's returned fromstd::queue::emplace()
is not actually a temporary, but rather a reference to internal member space.Env: using VSCode extension
jbenden.c-cpp-flylint
Thanks, ticket is here: https://trac.cppcheck.net/ticket/10895
Awesome, thanks!