From f495809973fee548ce9f8b19a0627f89665efd64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 7 May 2026 18:00:56 +0200 Subject: [PATCH 1/2] Fixed #14735 (dumpfile: Value::intvalue with negative value for unsigned expression) --- lib/token.cpp | 2 +- test/testsymboldatabase.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/token.cpp b/lib/token.cpp index b11e12bf0a7..d1e76ebdd67 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -1816,7 +1816,7 @@ void Token::printValueFlow(const std::vector& files, bool xml, std: outs += " valueType() && tok->valueType()->sign == ValueType::UNSIGNED) { + if (tok->valueType() && tok->valueType()->sign == ValueType::UNSIGNED && value.toString() != "!<=-1") { outs += "intvalue=\""; outs += MathLib::toString(static_cast(value.intvalue)); outs += '\"'; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 6efda65c11b..5101ff7a4c8 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -632,6 +632,8 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(stdintFunction); TEST_CASE(userDefinedLiteral); + + TEST_CASE(dumpValueNegative); // dumping negative impossible value } void array() { @@ -11444,6 +11446,18 @@ class TestSymbolDatabase : public TestFixture { ASSERT(!x->varId()); ASSERT(!x->variable()); } + + void dumpValueNegative() { // #14735 + GET_SYMBOL_DB("void f(unsigned int x) { a = x; }"); + const Token* x = Token::findsimplematch(tokenizer.tokens(), "x ;"); + ASSERT(x != nullptr); + std::ostringstream out; + x->printValueFlow({"test.cpp"}, true, out); + const std::string dump = out.str(); + const std::string expected = ""; + // dump should contain expected string, otherwise print the dump string + ASSERT_EQUALS(expected, dump.find(expected) == std::string::npos ? dump : expected); + } }; REGISTER_TEST(TestSymbolDatabase) From 3297e7ad3e1f6826a71a90fd5bb63ba10a026cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 7 May 2026 18:02:41 +0200 Subject: [PATCH 2/2] comment --- test/testsymboldatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 5101ff7a4c8..e981c8ea546 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -633,7 +633,7 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(userDefinedLiteral); - TEST_CASE(dumpValueNegative); // dumping negative impossible value + TEST_CASE(dumpValueNegative); // #14735 - dumping negative impossible value for unsigned expression } void array() {