Skip to content

Commit 539c2e5

Browse files
simartinDaniel Marjamäki
authored andcommitted
Fixed danmar#2932 (segmentation fault of cppcheck ( i / i ))
1 parent fc0f75f commit 539c2e5

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

lib/checkother.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,17 +1094,6 @@ void CheckOther::checkUnsignedDivision()
10941094
}
10951095
}
10961096
}
1097-
else if (Token::Match(tok, "|[|=|return|%op% %var% / %var%"))
1098-
{
1099-
1100-
//std::cout << "cicicicic" << std::endl;
1101-
char sign1 = varsign[tok->tokAt(1)->varId()];
1102-
char sign2 = varsign[tok->tokAt(3)->varId()];
1103-
if ((sign1 == 'u' && sign2 == 's') || (sign1 == 's' && sign2 == 'u'))
1104-
{
1105-
//udivError(tok);
1106-
}
1107-
}
11081097
}
11091098
}
11101099

test/testdivision.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class TestDivision : public TestFixture
6464
TEST_CASE(division7);
6565
TEST_CASE(division8);
6666
TEST_CASE(division9);
67+
TEST_CASE(division10);
6768
}
6869

6970
void division1()
@@ -198,6 +199,13 @@ class TestDivision : public TestFixture
198199
TODO_ASSERT_EQUALS("unsigned division",
199200
"", errout.str());
200201
}
202+
203+
void division10()
204+
{
205+
// Ticket: #2932 - don't segfault
206+
check("i / i");
207+
ASSERT_EQUALS("", errout.str());
208+
}
201209
};
202210

203211
REGISTER_TEST(TestDivision)

0 commit comments

Comments
 (0)