From a5442c8070be807d95263f854fafacb3d63cfd96 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:16:52 +0100 Subject: [PATCH 1/5] Update vf_analyzers.cpp --- lib/vf_analyzers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index e14af7a9c98..a99b525c250 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -139,7 +139,7 @@ struct ValueFlowAnalyzer : Analyzer { return result; } ConditionState lhs = analyzeCondition(tok->astOperand1(), depth - 1); - if (lhs.isUnknownDependent()) + if (lhs.isUnknownDependent() || !tok->astOperand2()) return lhs; ConditionState rhs = analyzeCondition(tok->astOperand2(), depth - 1); if (rhs.isUnknownDependent()) From 8004db4788ddec7918b08ab2cfbbd87a8dc66be1 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:19:07 +0100 Subject: [PATCH 2/5] Update testnullpointer.cpp --- test/testnullpointer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 1eb01edfcce..1de009fd71c 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -2458,6 +2458,14 @@ class TestNullPointer : public TestFixture { " if (h(i) && *i == 1) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void f(int i) {\n" // #13797 + " int* p = nullptr;\n" + " if (!i) {\n" + " *p = 0;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4:10]: (error) Null pointer dereference: p [nullPointer]\n", errout_str()); } void nullpointer78() // #7802 @@ -3929,7 +3937,9 @@ class TestNullPointer : public TestFixture { " std::string s(p);\n" " return s;\n" "}\n", dinit(CheckOptions, $.inconclusive = true)); - ASSERT_EQUALS("", errout_str()); + TODO_ASSERT_EQUALS("", + "[test.cpp:6:17]: (warning, inconclusive) Possible null pointer dereference: p [nullPointer]\n", + errout_str()); check("void f() {\n" // #11078 " const char* p = nullptr;\n" From 7eeb4278d7369e260f0918bcefd8421652a621d6 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:35:43 +0100 Subject: [PATCH 3/5] Update testnullpointer.cpp --- test/testnullpointer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 1de009fd71c..2c8d82ca14b 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -3938,7 +3938,7 @@ class TestNullPointer : public TestFixture { " return s;\n" "}\n", dinit(CheckOptions, $.inconclusive = true)); TODO_ASSERT_EQUALS("", - "[test.cpp:6:17]: (warning, inconclusive) Possible null pointer dereference: p [nullPointer]\n", + "[test.cpp:6:17]: (warning, inconclusive) Possible null pointer dereference: p [nullPointer]\n", errout_str()); check("void f() {\n" // #11078 From 91161abe27d476aefb05e0870b3300bd760a3f16 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Fri, 30 Jan 2026 19:50:42 +0100 Subject: [PATCH 4/5] Fix warnings --- lib/checkunusedfunctions.cpp | 2 +- lib/library.cpp | 2 +- lib/symboldatabase.cpp | 2 +- lib/vf_analyzers.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 7edaff6c241..f6daec51f20 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -385,7 +385,7 @@ bool CheckUnusedFunctions::check(const Settings& settings, ErrorLogger& errorLog if (func.filename != "+") filename = func.filename; errors.emplace_back(filename, func.fileIndex, func.lineNumber, func.column, it->first); - } else if (func.isC && !func.isStatic && !func.usedOtherFile) { + } else if (func.isC && !func.isStatic) { std::string filename; if (func.filename != "+") filename = func.filename; diff --git a/lib/library.cpp b/lib/library.cpp index ad5ea13a3ed..5b6af91ac4a 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -210,7 +210,7 @@ Library::Error Library::load(const char exename[], const char path[], bool debug tinyxml2::XMLError error = xml_LoadFile(doc, fullfilename.c_str()); if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) { // only perform further lookups when the given path was not absolute - if (!is_abs_path && error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) + if (!is_abs_path) { std::list cfgfolders; #ifdef FILESDIR diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index e1f7a28d68d..05dd605ea21 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1023,7 +1023,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization() if (var.isClass() && !var.isReference()) { if (var.type()) { // does this type need initialization? - if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault() && !var.isStatic()) + if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault()) needInitialization = true; else if (var.type()->needInitialization == Type::NeedInitialization::Unknown) { if (!(var.valueType() && var.valueType()->type == ValueType::CONTAINER)) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index a99b525c250..ec026f2f487 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -1202,7 +1202,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer { return false; if (value.isImpossible()) return false; - if (isConditional() && !value.isKnown() && !value.isImpossible()) + if (isConditional() && !value.isKnown()) return true; if (value.isSymbolicValue()) return false; From 34de8aa7b7d18e590f097351b5a0ff12f921bdff Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Fri, 30 Jan 2026 19:50:49 +0100 Subject: [PATCH 5/5] Adjust test --- test/testnullpointer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 2c8d82ca14b..96e188075e4 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -3937,9 +3937,8 @@ class TestNullPointer : public TestFixture { " std::string s(p);\n" " return s;\n" "}\n", dinit(CheckOptions, $.inconclusive = true)); - TODO_ASSERT_EQUALS("", - "[test.cpp:6:17]: (warning, inconclusive) Possible null pointer dereference: p [nullPointer]\n", - errout_str()); + ASSERT_EQUALS("[test.cpp:6:17]: (warning, inconclusive) Possible null pointer dereference: p [nullPointer]\n", + errout_str()); check("void f() {\n" // #11078 " const char* p = nullptr;\n"