Skip to content

Commit b571941

Browse files
committed
cppcheck-opensource#8206 - Added a regression test
1 parent 260eb4a commit b571941

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/testcondition.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,6 +3087,14 @@ class TestCondition : public TestFixture {
30873087
"}");
30883088
ASSERT_EQUALS("", errout.str());
30893089

3090+
// #8206 - knownCondition always false
3091+
check("void f(int i)\n"
3092+
"{\n"
3093+
" if(i > 4)\n"
3094+
" for( int x = 0; i < 3; ++x){}\n" // <<
3095+
"}");
3096+
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Condition 'i<3' is always false\n", errout.str());
3097+
30903098
// Skip literals
30913099
check("void f() { if(true) {} }");
30923100
ASSERT_EQUALS("", errout.str());

0 commit comments

Comments
 (0)