File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -1728,6 +1728,9 @@ void CheckOther::checkConstVariable()
17281728 retTok = retTok->astOperand2 ();
17291729 if (Token::simpleMatch (retTok, " &" ))
17301730 retTok = retTok->astOperand1 ();
1731+ ValueFlow::Value ltVal = ValueFlow::getLifetimeObjValue (retTok);
1732+ if (ltVal.isLifetimeValue () && ltVal.tokvalue ->varId () == var->declarationId ())
1733+ return true ;
17311734 return ValueFlow::hasLifetimeToken (getParentLifetime (retTok), var->nameToken (), *mSettings );
17321735 }))
17331736 continue ;
Original file line number Diff line number Diff line change @@ -3964,6 +3964,9 @@ class TestOther : public TestFixture {
39643964
39653965 check("void push(V& v) { v.push_back({ .x = 1 }); }"); // #14010
39663966 ASSERT_EQUALS("", errout_str());
3967+
3968+ check("size_t* f(std::array<uint8_t, 128>& a) { return reinterpret_cast<size_t*>(a.data()); }\n"); // #14074
3969+ ASSERT_EQUALS("", errout_str());
39673970 }
39683971
39693972 void constParameterCallback() {
You can’t perform that action at this time.
0 commit comments