Some new GCC6 warnings


Some new nice warnings added to GCC6:

-Wlogical-op warns when the operands of a logical operator are the same:

if (point.x < 0 || point.x < 0)

-Wduplicated-cond catches duplicated tests in if-else-if chains like:

if (foo) {
} else if (foo) {

-Wtautological-compare detects comparisons of variables against themselves:

if (x > x) {

All such bugs are quite common. And I guess they are present in Rust code too. But such lints are perhaps better inside Clippy…


Actually they should all be covered by clippy already. For #1 and #2, there is a distinction between expressions that are definitely without side effect, and such that could have a side effect, in which case the duplication could make sense. Don’t know how GCC does it.