Fix #11914 Crash when checking widelands (#5404)

This commit is contained in:
chrchr-github 2023-09-05 11:12:04 +02:00 committed by GitHub
parent 03026c7304
commit 7a79366ba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -2539,7 +2539,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings,
// Check addressof
if (tok2->astParent() && tok2->astParent()->isUnaryOp("&")) {
if (isVariableChanged(tok2->astParent(), indirect + 1, settings, depth - 1))
if (isVariableChanged(tok2->astParent(), indirect + 1, settings, cpp, depth - 1))
return true;
} else {
// If its already const then it cant be modified

View File

@ -7165,6 +7165,12 @@ private:
" (*printf)(\"%s %i\", strerror(errno), b ? 0 : 1);\n"
"};\n";
valueOfTok(code, "?");
code = "void f(int i) {\n" // #11914
" int& r = i;\n"
" int& q = (&r)[0];\n"
"}\n";
valueOfTok(code, "&");
}
void valueFlowHang() {