courbet added a comment.

OK, here's an analysis of 100 instances of a check that would warn on all fully 
implicit (no C/static/reinterpret/...) casts from float/double to integral: 
link 
<https://docs.google.com/document/d/1X1ostfsvwEDD3I4LLSKgDIF131lAUElRUg2ONyr_Xjg/edit?usp=sharing>
I don't expect the analysis to be perfect, but that gives us a better idea of 
what to expect.

- A bit more than 1/3 of instances are OK and should be using a cast.
- A bit less than 1/4 of instances is brittle code and should use int types.
- The two false positive cases are easy to handle.
- I was surprised about the "truth value of float" one. I think we should 
provide a fix to turn `!f` this into `f != 0.0f`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to