
2009/11/17 Patrick Horgan <phorgan1@gmail.com>:
For signed integral types, using !!val folds all the negative and positive non-zero values into true. It's the equivalent of val!=0. Sometimes, people really mean to test for val!=0, sometimes they really mean val>0. !!val will still be true even if val is -42. Why not say what you mean? It's communicates better and leads to less subtle bugs. Use one of val!=0, val>0, or whatever test you really mean to do. I understand !!val is the same as val!=0 when I read it and hope that the original programmer also understood that. When I maintain someone else's code, and see val!=0 I feel more happy fuzzies that they said what they meant.
It's worth noting that if the warning turns up in generic code, you should make sure your workaround doesn't add additional requirements to the type being tested. Daniel