Consider the following C snippit: if (x == 5) { ... } else if (x == 5) { ... } I've made a typo in the 'else if' and accidentally tested condition. It would be nice it clang could warn when it sees this. With raw ints it's easy to see the mistake, but when they are constants, and two constants accidentally have the same value, it's harder to find. It would be happy with this in either the compiler or static analyzer.
Interesting to note that PVS-Studio can catch this, and found an example of it within clang's own codebase: http://software.intel.com/en-us/blogs/2011/08/08/pvs-studio-vs-clang/ (scroll down to "Copy-Paste error N5") "V523 The 'then' statement is equivalent to the 'else' statement. LLVMInstCombine instcombineandorxor.cpp 1387"
*** This bug has been marked as a duplicate of bug 9952 ***
Nico, I don't think you should have marked this as duplicate of bug 9952. bug 9952 is talking about what PVS Studio calls: "V501. There are identical sub-expressions to the left and to the right of the 'foo' operator" http://www.viva64.com/en/d/0090/ bug 9193 (this bug) is talking about what PVS Studio calls: "V517. The use of 'if (A) {...} else if (A) {...}' pattern was detected." http://www.viva64.com/en/d/0106/ I'd like to see both, bug don't see the reason to conflate them.