MATLAB: Illegally dereferenced pointer may be incorrect

code proverPolyspace Code Prover

Hi Technical Support Team
I got a concern about orange warning at line 1065. Because array u1t_ArSrcSignalData[] is not NULL and index of it as 0.
Why Code Power throw out the orange warning at there?
Please take a look pic:
Please take a look pic below to see tooltip to get more info:

Best Answer

The orange warning does not mean that the pointer is null. In fact, you can see in the message that the pointer is not null. (This is also why your later if statement appeared grey since the if condition is always true.)
The orange warning appears because the pointer is suspected to be pointing outside the allowed buffer. The part of the message that says "may be outside bounds" indicates this.
The other things that I can deduce from the message are:
  • The pointer might be some kind of a global pointer, since it points to what appears like local variables in different functions.
  • The second line of the message indicating "If appropriate, applying DRS to ..." indicates that the tool is having to make an assumption on that particular line for the variable pu1t_SignalData (because its value is not known), which leads to a possibly imprecise result. You can externally constrain this variable if you want and that might lead to the orange going away. See Specify External Constraints.
However, since the tool deduces that there are 67 (!) different candidates for what the pointer might point to, I am inclined to think there might be an overapproximation happening somewhere in the middle too. This will require deeper investigation.