Local Variable was change range value but not assigned

3 visualizaciones (últimos 30 días)
Tran Thang
Tran Thang el 15 de Dic. de 2020
Editada: Tran Thang el 30 de Dic. de 2020
Hi Matlab Support teams!
I'm using Polyspace R2019a, and i got a problem about local Variable
At line 5970, range value of local variable "u1t_InRnewEndPntIdx" = [0..8],
Please take a look following pic 1:
But at line 5980, range value of local variable "u1t_InRnewEndPntIdx" = [0..17]
Please take a look following pic 2:
u1t_InRnewEndPntIdx is not updated or assigned from line 5971 to 5980, why does it change range value?
Please help me answer the question above.
BR
Hoang Hiep

Respuesta aceptada

Anirban
Anirban el 16 de Dic. de 2020
Hi,
One of the reasons could be that Code Prover is considering the case where the if branch, where u1t_InRnewEndPntIdx is assigned (line 5970), is bypassed. So the range outside the for loop is a combination of ranges in the if branch and any range u1t_InRnewEndPntIdx had before the for loop.
There is something you can try. Place this line:
#pragma Inspection_Point u1t_InRnewEndPntIdx
in the else branch with the break and see the tooltip on u1t_InRnewEndPntIdx. This might help you confirm this hypothesis.
  8 comentarios
Anirban
Anirban el 28 de Dic. de 2020
To answer your other questions:
  • You cannot add the pragma on an entire array.
  • The analysis losing precision is not a problem per se because if the range 0..17 does not cause an issue like an overflow, the smaller range 0..9 is already checked and will still not cause an overflow. So, the greens are fine despite the loss of precision. However, the loss of precision does cause a problem of understanding if you are trying to track the ranges. In this case, as I answered before, it would be possible with the full context of the code, to get a sense of what led to the loss of precision and how adding some more information through the pragma in the else branch, the precision is regained. But Technical Support will have to look through the ranges on the other variables in the loop, the checks in the loop and other information provided by the tool. They can also explain to you what they looked for and how they arrived at their explanation.
Tran Thang
Tran Thang el 30 de Dic. de 2020
Editada: Tran Thang el 30 de Dic. de 2020
Hi Anirban !
I see CP result that have full source?, Besides I can't decide whether given it to Technical Support .
Your answer also help me workaround and solve it partly.
From the bottom, Thank you for your answer.
BR

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by