Possible division by zero - fails to detect

QcoreUserQcoreUser Posts: 1

Hello.
I am running a static analysis checks with Parasoft C/C++ test. And I encountered the following issue: passing a zero parameter to a function which afterwards uses it to divide is not always detected/reported. For example:

void some_function()
{
test_function(0);
}

void test_function(int parameter)
{
int var = 5 / parameter;
}

Usually it is detected, But if I add some number of function before calling test_function(0), the issue will not be reported. Like this:

void some_function()
{
other_function_1();
other_function_2();
...
other_function_n();
test_function(0);
}

Anyone encountered or knows why this works this way?

Sign In or Register to comment.