Some new GCC6 warnings


#1

Some new nice warnings added to GCC6:

https://gnu.wildebeest.org/blog/mjw/2016/02/15/looking-forward-to-gcc6-many-new-warnings/

-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…


#2

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.