Skip to content

Commit

Permalink
Fix #11789 FP knownConditionTrueFalse with std::vector::size()
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 23, 2023
1 parent 04476bc commit d14222c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
10 changes: 10 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4895,6 +4895,16 @@ class TestCondition : public TestFixture {
" 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() {
Expand Down

0 comments on commit d14222c

Please sign in to comment.