From a762511067076b2b55f02560b0a5039e06ed8d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 9 Jan 2017 22:28:55 +0100 Subject: [PATCH] Fixed #7888 (1.77 false positive from knownConditionTrueFalse with sizeof(int) == sizeof(long)) --- lib/valueflow.cpp | 8 -------- test/testvalueflow.cpp | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 9d633f852..e96c9c704 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -728,35 +728,27 @@ static Token * valueFlowSetConstantValue(const Token *tok, const Settings *setti const ValueType &vt = ValueType::parseDecl(tok2,settings); if (vt.pointer) { ValueFlow::Value value(settings->sizeof_pointer); - value.setKnown(); setTokenValue(const_cast(tok->next()), value, settings); } else if (vt.type == ValueType::Type::CHAR) { ValueFlow::Value value(1); - value.setKnown(); setTokenValue(const_cast(tok->next()), value, settings); } else if (vt.type == ValueType::Type::SHORT) { ValueFlow::Value value(settings->sizeof_short); - value.setKnown(); setTokenValue(const_cast(tok->next()), value, settings); } else if (vt.type == ValueType::Type::INT) { ValueFlow::Value value(settings->sizeof_int); - value.setKnown(); setTokenValue(const_cast(tok->next()), value, settings); } else if (vt.type == ValueType::Type::LONG) { ValueFlow::Value value(settings->sizeof_long); - value.setKnown(); setTokenValue(const_cast(tok->next()), value, settings); } else if (vt.type == ValueType::Type::LONGLONG) { ValueFlow::Value value(settings->sizeof_long_long); - value.setKnown(); setTokenValue(const_cast(tok->next()), value, settings); } else if (vt.type == ValueType::Type::FLOAT) { ValueFlow::Value value(settings->sizeof_float); - value.setKnown(); setTokenValue(const_cast(tok->next()), value, settings); } else if (vt.type == ValueType::Type::DOUBLE) { ValueFlow::Value value(settings->sizeof_double); - value.setKnown(); setTokenValue(const_cast(tok->next()), value, settings); } } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 7545a0412..47460c165 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -493,6 +493,7 @@ private: values = tokenValues(code,"( int )"); ASSERT_EQUALS(1U, values.size()); ASSERT_EQUALS(settings.sizeof_int, values.back().intvalue); + ASSERT_EQUALS(false, values.back().isKnown()); // value is different on different platforms (#7888) code = "void f() {\n" " struct S *a[10];"