Just upgraded from cppcheck v1.33 to v1.78. The code below was formerly flagged as Divide by zero, but is ignored with v1.78.
float rate = 0
float range = 0;
rate= 1.1
rate = rate/range;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This one is intentional. One some platforms the result will be INF.
I think this calculation can crash on some embedded platforms. So if anybody has the time to add a platform configuration we can warn about that properly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just upgraded from cppcheck v1.33 to v1.78. The code below was formerly flagged as Divide by zero, but is ignored with v1.78.
float rate = 0
float range = 0;
rate= 1.1
rate = rate/range;
This one is intentional. One some platforms the result will be INF.
I think this calculation can crash on some embedded platforms. So if anybody has the time to add a platform configuration we can warn about that properly.
FYI, cat /etc/*release displays:
Red HatEnterprise Linux Client release 5.5 (Tikanga)
5.4 Redhawk Linux (Lima)
ok.. so I assume your result will be INF.
on my ubuntu machine this program writes "inf" on the screen. Does it write "inf" for you too?
Here is a platform configuration file: https://github.com/danmar/cppcheck/blob/master/platforms/avr8.xml
This is where somebody should add the possibility to say that floating point division by zero should be warned about.
I ran the test you supplied above, and I got "inf", too.