Skip to content

Commit 6c750d9

Browse files
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.
1 parent 55581fc commit 6c750d9

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

cfg/std.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8855,7 +8855,6 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
88558855
<podtype name="uintptr_t,std::uintptr_t" sign="u"/>
88568856
<podtype name="intmax_t,std::intmax_t" sign="s"/>
88578857
<podtype name="uintmax_t,std::uintmax_t" sign="u"/>
8858-
<podtype name="size_t,std::size_t" sign="u"/>
88598858
<podtype name="std::string::size_type" sign="u"/>
88608859
<podtype name="std::wstring::size_type" sign="u"/>
88618860
<podtype name="std::u16string::size_type" sign="u"/>

test/testcondition.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4895,6 +4895,16 @@ class TestCondition : public TestFixture {
48954895
" return p != NULL && q != NULL && p == NULL;\n"
48964896
"}\n");
48974897
ASSERT_EQUALS("[test.cpp:2]: (style) Return value 'p==NULL' is always false\n", errout.str());
4898+
4899+
check("struct S {\n" // #11789
4900+
" std::vector<int> v;\n"
4901+
" void f(int i) const;\n"
4902+
"};\n"
4903+
"void S::f(int i) const {\n"
4904+
" int j = i - v.size();\n"
4905+
" if (j >= 0) {}\n"
4906+
"}\n");
4907+
ASSERT_EQUALS("", errout.str());
48984908
}
48994909

49004910
void alwaysTrueContainer() {

0 commit comments

Comments
 (0)