[PATCH] New warning for mismatch between not and and/or operators.
Richard Trieu
rtrieu at google.com
Thu Apr 2 18:08:17 PDT 2015
In http://reviews.llvm.org/D5765#134133, @danielmarjamaki wrote:
> I am personally a bit skeptic about this.
>
> what does it solve to use:
>
> a = !b || !c;
>
>
> instead of:
>
> a = !b | !c;
>
>
> If it's only stylistic .. then why not let the programmer decide which way is better.
The same reason Clang suggests parentheses for possible order of operations bugs. It is easy to make such bugs and the correction helps make the code more readable. Perhaps the opposite suggestion should also be made?
a = ~b | ~c;
which does change how the code works.
> I am not saying that I am against this.. just that I am a bit skeptic.
Switching from bitwise to logical operator also produced different code when compiled in at least one case. See https://llvm.org/bugs/show_bug.cgi?id=22723
http://reviews.llvm.org/D5765
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list