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];"