フィルターのクリア

CodeProver does not detect overflow for non-volatile global variables

1 回表示 (過去 30 日間)
Benjamin Colle
Benjamin Colle 2018 年 1 月 3 日
コメント済み: Benjamin Colle 2018 年 1 月 5 日
Hello,
In an attempt to check the following ticket https://ch.mathworks.com/matlabcentral/answers/374199-codeprover-does-not-detect-overflow-underflow-with-unsigned-variables, I have noticed that CodeProver does not detect potential overflow when manipulating global variables which are not volatile. If I add the volatile keyword, CodeProver does raise a warning.
int8_t a, b, c;
volatile int8_t d, e, f;
void test (void){
a = b-c; // No warning
d = e-f; // Warning raised
}
I have tried also by making some computation on these variables somewhere else in the code, but the result is the same.
Is this a confirmed behavior on your side?

採用された回答

Alexandre De Barros
Alexandre De Barros 2018 年 1 月 4 日
Hello,
I cannot reproduce your results: I have overflows for both volatile and non-volatile variables.
Are b and c full-range in your results ?
Alex
  2 件のコメント
Benjamin Colle
Benjamin Colle 2018 年 1 月 4 日
Thanks for your answer.
Even without values assigned prior to this operation, I get the behaviour. But at first (with int16 variables), I tried with b = -32768 and c = 32767.
Benjamin Colle
Benjamin Colle 2018 年 1 月 5 日
After investigation, it has been understood and found that:
- Code Prover, when a main is available, initializes variables to 0
- The assignment of values to those variables was done after the call of the function dealing with those variables
Therefore, Code Prover considered 0-value variables, which indeed do not overflow.
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by