File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -479,7 +479,7 @@ namespace ValueFlow
479
479
if (!isComputableValue (parent, value1))
480
480
continue ;
481
481
for (const Value &value2 : parent->astOperand2 ()->values ()) {
482
- if (value1.path != value2.path )
482
+ if (value1.path != value2.path && value1. path != 0 && value2. path != 0 )
483
483
continue ;
484
484
if (!isComputableValue (parent, value2))
485
485
continue ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ class TestOther : public TestFixture {
59
59
TEST_CASE(zeroDiv18);
60
60
TEST_CASE(zeroDiv19);
61
61
TEST_CASE(zeroDiv20); // #11175
62
+ TEST_CASE(zeroDiv21);
62
63
63
64
TEST_CASE(zeroDivCond); // division by zero / useless condition
64
65
@@ -679,6 +680,17 @@ class TestOther : public TestFixture {
679
680
ASSERT_EQUALS("[test.cpp:4]: (error) Division by zero.\n", errout_str());
680
681
}
681
682
683
+ void zeroDiv21()
684
+ {
685
+ check("int f(int n) {\n"
686
+ " return 1 / ((1 / n) - 1);\n"
687
+ "}\n"
688
+ "int g() {\n"
689
+ " return f(1);\n"
690
+ "}\n");
691
+ ASSERT_EQUALS("[test.cpp:2]: (error) Division by zero.\n", errout_str());
692
+ }
693
+
682
694
void zeroDivCond() {
683
695
check("void f(unsigned int x) {\n"
684
696
" int y = 17 / x;\n"
You can’t perform that action at this time.
0 commit comments