Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,8 @@ static void valueFlowLifetimeFunction(Token *tok, const TokenList &tokenlist, Er
}
if (Function::returnsReference(f))
return;
if (astIsContainerString(tok->next()) && !astIsContainerView(tok->next()))
Comment thread
chrchr-github marked this conversation as resolved.
Outdated
return;
std::vector<const Token*> returns = Function::findReturns(f);
const bool inconclusive = returns.size() > 1;
bool update = false;
Expand Down
9 changes: 9 additions & 0 deletions test/testautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2962,6 +2962,15 @@ class TestAutoVariables : public TestFixture {
" int m;\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("std::string to_string(const char* p) {\n" // #14818
" return p;\n"
"}\n"
"std::string get() {\n"
" std::string s;\n"
" return to_string(s.c_str());\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void danglingLifetimeContainerView()
Expand Down
Loading