Why does Polyspace report a larger than expected number of execution paths in terms of the compute code metrics?

4 views (last 30 days)
It is sought to verify the code snippet below using Polyspace Bug Finder and have the Code Metrics computed,
 
void myfun (void) {
  while(1) {
    if (1){
      a = 10;
    }
  }
  if (0) {
    a++;
  }
}
Knowing that the first nested control structure introducing three (3) execution paths and the second if-control structure introduces two (2) execution paths, I would expect tha the total number of execution paths that are reported in the Code Metrics of the Polyspace results is five (5).
However, the Number of Paths code metric of Polyspace reports six (6) execution paths in this case.
Why does Polyspace report a larger than expected number of execution paths in terms of the compute code metrics?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Nov 2021
Please note that subsequent control structures in a code have a multiplying and not an adding effect to the previously computed number of execution paths. Thus in this case the total number of execution paths is six (6).

More Answers (0)

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!