A new command-line option -Wlogical-not-parentheses has been added for the C and C++ compilers, which warns about "logical not" used on the left hand side operand of a comparison.

bool not_equal(int x, int y) {
  return !x == y;  // warn here
}

return !(x == y);  // first fix-it, to negate comparison.

return (!x) == y;  // second fix-it, to silence warning.

I'll wait for your opinions before asking for this error in D.


New warnings -Wsuggest-final-types and -Wsuggest-final-methods helps developers to annotate programs by final specifiers (or anonymous namespaces) in the cases where code generation improves. These warnings can be used at compile time, but they are more useful in combination with link-time optimization.

Some info:
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg00119.html

I have added this to Bugzilla, it can please the "final on default" crowd:
https://issues.dlang.org/show_bug.cgi?id=13798

Bye,
bearophile

Reply via email to