MATLAB Answers

Code Power judge color warning that is not consistent

1 view (last 30 days)
Tran Thang
Tran Thang on 6 Jul 2021
Edited: Anirban on 9 Jul 2021
Hi @Anirban,
I'm counting number of orange warnings. I'm confusing the result of orange warnings from Code Power.
At version 2.2.12, Line 453 have 2 warnings that consis of a orange(Non-initialized variable) and a green(Illegally dereferenced pointer). Please take a look shoot pic below:
At version 2.2.17, Line 929 have 2 warnings that consis of a orange(Non-initialized variable) and a orange(Illegally dereferenced pointer). Please take a look shoot pic below:
Line 453 of version 2.2.12 and Line 929 of version 2.2.17, Array ptt_mappdata and variable u2t_index_x are same size of array and value correspondingly.
Please let me know why Code Power judge color warning that is not consistent (
  • 453 Illegally dereferenced pointer in version 2.2.12: Green
  • 929 Illegally dereferenced pointer in version 2.2.17: Orange)
Br/ Thang Tran
  2 Comments
Tran Thang
Tran Thang on 8 Jul 2021
version 2.2 corresponds to release 2016b => No, It is my source code version. I are using PolySpace Version R2020b and run for 2 source code. I'm talking about different color in 2 source codes. I'm sure that they are same in file source libmap.c.
which variable is non-initialized? Which variable does the orange warning refer to
With source code version 2.2.12, non-initialized is ptt_mapdata[u2t_index_x] and Illegally dereferenced pointer ptt_mapdata[] is green. Please take a look shot pic below: (Focus Line 453)
With source code version 2.2.17, non-initialized is ptt_mapdata[u2t_index_x] and Illegally dereferenced pointer ptt_mapdata[] is Orange. Please take a look shot pic below: (Focus line 929)

Sign in to comment.

Answers (1)

Anirban
Anirban on 9 Jul 2021
Edited: Anirban on 9 Jul 2021
Hi,
Are you sure u2t_index_x has the exact same range of values on line 453 in one version and line 929 in the other version? If you hover on u2t_index_x, you should see the range of values.
Is ptt_mappdata dynamically allocated? This means that its size changes during its lifetime. Is the allocation happening the exact same way in both versions? I cannot tell from the screenshots alone.
In other words, the way you reasoned was the following: since the array size and index are the same in both versions, the check color should not have changed. Since the code changed significantly (line 453 in one version and line 929 in the other), I cannot confirm your assertion about array size and index staying the same, based on the screenshots of the lines alone. You can try to confirm this yourself by trying to look for answers to the above two questions.
Another approach (other than contacting Support) would be to see the error call graphs for the Illegally dereferenced pointer-s in both versions. Is it the same function sequence that leads to the check in both versions?
  • If the function sequences are not the same, maybe now you can trace the orange to some new function call that happened.
  • If the function sequences are the same, then it gets harder. You have to do a diff of the functions in that call sequence between the two versions of the code and see whether stuff that changed between the versions affects the array access.

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by