while using the trial version of a static analysis product, I tryed it with OCE to evaluate it with a very big solution :)
Surely I can't disclose the result log, since it won't be ethically correct , but I'm reporting the problem. Probably clang or MSVC /analize could report similar issues.
Apart the usual false positives, there is a HUGE quantity of float comparisons done without a tolerance range (i.e. using operator ==).
With HUGE quantity i mean almost everywhere (~1500 possible entries)...
While in some cases it can be ok (i.e. checking some pre-assigned values), most cases require to check against a tolerance (fabs(A)
Standard_Real delt1 = Abs(prml-prmf);
Standard_Real delt2 = Abs(period-delt1);
if (delt1 == 0 || delt2 == 0)
you surely know better than me that this check is a potential bug. Also the result is influenced by OS,machine and compiler settings.
- What is the appropriate function/functions to use to check the values for 0 or for equality?
- I know you usually work on a per-case basis (it is also stated somewhere in this forum). But, do you plan to do something for these global issues?
- In my small experience, the tolerance used to do these checks can influence the whole result of an algorithm. While using a very small precision (i.e. Precision::Confusion) can at least solve the "float comparison issue", using a precision related to the kind of value you are checking can be better or more appropriate. If you are checking a sqrt delta, it is very different from checking two vertex position values, and maybe two different precisions should be used. Also, checking a "divisor" with a too small tolerance, may lead to a very big floating number which results in a loss of precision if used in subsequent operations.
Is there a "use-pattern" in OCC for this?
Surely solving this could give OCC a stability boost, but could also mess up things as potential breaking change!
p.s. I didn't know where to put this topic, so I choose the roadmap section,maybe one section for development discussions could be added?