Fix #11789 FP knownConditionTrueFalse with std::vector::size() (#5184)

There is special handling for `size_t` in
`ValueType::fromLibraryType()`, which gets preempted if it is also
configured as a podtype.
This commit is contained in:
chrchr-github 2023-06-23 20:31:25 +02:00 committed by GitHub
parent 55581fc2e9
commit 6c750d9ae9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -8855,7 +8855,6 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<podtype name="uintptr_t,std::uintptr_t" sign="u"/>
<podtype name="intmax_t,std::intmax_t" sign="s"/>
<podtype name="uintmax_t,std::uintmax_t" sign="u"/>
<podtype name="size_t,std::size_t" sign="u"/>
<podtype name="std::string::size_type" sign="u"/>
<podtype name="std::wstring::size_type" sign="u"/>
<podtype name="std::u16string::size_type" sign="u"/>

View File

@ -4895,6 +4895,16 @@ private:
" return p != NULL && q != NULL && p == NULL;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2]: (style) Return value 'p==NULL' is always false\n", errout.str());
check("struct S {\n" // #11789
" std::vector<int> v;\n"
" void f(int i) const;\n"
"};\n"
"void S::f(int i) const {\n"
" int j = i - v.size();\n"
" if (j >= 0) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueContainer() {