File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1723,7 +1723,7 @@ void CheckOther::checkConstVariable()
17231723 if (retTok->varId () == var->declarationId ())
17241724 return true ;
17251725 while (retTok && retTok->isCast ())
1726- retTok = retTok->astOperand2 ();
1726+ retTok = retTok->astOperand2 () ? retTok-> astOperand2 () : retTok-> astOperand1 () ;
17271727 while (Token::simpleMatch (retTok, " ." ))
17281728 retTok = retTok->astOperand2 ();
17291729 if (Token::simpleMatch (retTok, " &" ))
Original file line number Diff line number Diff line change @@ -3967,6 +3967,13 @@ class TestOther : public TestFixture {
39673967
39683968 check("size_t* f(std::array<uint8_t, 128>& a) { return reinterpret_cast<size_t*>(a.data()); }\n"); // #14074
39693969 ASSERT_EQUALS("", errout_str());
3970+
3971+ check("struct S { int i; };\n" // #14231
3972+ "void* f(S& s, int& v) {\n"
3973+ " v = s.i;\n"
3974+ " return (void*)&s;\n"
3975+ "}\n"); // don't crash
3976+ ASSERT_EQUALS("", errout_str());
39703977 }
39713978
39723979 void constParameterCallback() {
You can’t perform that action at this time.
0 commit comments