Thanks for reporting this. The MISRA 2012 document doesn't explicitly define this situation, but it seems right for me. C89 standard defines enum members as enumeration contants at ch. 6.4.4.3, and they are always known at compile time.
I think this should not lead to R18.8 warnings. I will create a ticket when Trac is available.
Hello,
I'm getting a false positive on the following code:
Error:
Here is the definition of FAULT_MAX:
FAULT_MAX is always going to be the same value during runtime, so I think this is a false positive.
Regards,
Amir
Hello, Amir,
Thanks for reporting this. The MISRA 2012 document doesn't explicitly define this situation, but it seems right for me. C89 standard defines enum members as enumeration contants at ch. 6.4.4.3, and they are always known at compile time.
I think this should not lead to R18.8 warnings. I will create a ticket when Trac is available.
Update: I created the ticket https://trac.cppcheck.net/ticket/9913
Last edit: Georgiy Komarov 2020-09-25
Thank you!
BTW when I move the variables from function scope to file scope, the warning disappears.
This PR should fix it: https://github.com/danmar/cppcheck/pull/2823