How to Fix Polyspace CodeProver Orange Overflow errors

7 次查看(过去 30 天)
Hello,
I am getting the below Orange Overflow error due to operator *
How to fix these Overflow errors as we know this operation is not going to generate a result bigger than the datatype of int32 ?
  3 个评论
Dinesh Kumar
Dinesh Kumar 2024-8-12
Hello,
Do we need to justify the errors ? or we can provide some fixes for these errors ?
DGM
DGM 2024-8-12
I'm not sure what you mean by needing justification. These three questions are valid and deserve an answer, but to my understanding, they constitute three different instances of a warning message of similar form -- the tool is complaining that an arithmetic operation may cause data loss, but it isn't aware of higher-level constraints which may prevent the issue.
I don't have or use Polyspace, so I can't direcltly provide a confident answer myself. I may be blind to some details, but I estimate that a generalized answer which answers one of the questions should answer all three. If I'm wrong, someone is free to correct me. My uncertainty is why I chose to not close these two which I only think are duplicates. I'm just trying to make sure that someone more informed can see the multiplicity of questions of similar form. Hopefully someone can help you out.

请先登录,再进行评论。

回答(1 个)

Akshat Dalal
Akshat Dalal 2024-8-17
Hi Dinesh,
The unexpected orange integer overflow warning can be due to the below two reasons:
  1. Shared Variable: If you are performing multitasking analysis in Polyspace, the variable 'sx32_LastMeas' could be shared. Consequently, Polyspace detects that its value might change between instances.For more information on configuring shared variables during multitasking analysis, please refer to the following documentation: www.mathworks.com/help/releases/R2020b/codeprover/ug/protections-for-shared-variables.html
  2. Volatile Variable: If 'sx32_LastMeas' is declared as a Volatile variable, Polyspace treats it as a 'permanent random' variable because its value can change within its entire range between consecutive read accesses. For more information on Volatile variables in Polyspace, you can refer the following documentation: www.mathworks.com/help/releases/R2020b/polyspace_ada/ada_ref/volatile-variables.html
Therefore, if 'sx32_LastMeas' falls into either of these categories, Polyspace considers its entire range for analysis, sint32 in this case. Therefore, Polyspace reports a probable 'Integer overflow' Orange check even if it is theoretically not possible.

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by