This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/81320] -Wlogical-op diagnostic depends on comparison' order
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 11 Jul 2017 13:27:38 +0000
- Subject: [Bug middle-end/81320] -Wlogical-op diagnostic depends on comparison' order
- Auto-submitted: auto-generated
- References: <bug-81320-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81320
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-07-11
Ever confirmed|0 |1
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
We fail to warn in f2 because we compare the expression in the conditional
sequentially, but that doesn't work due to left-to-right associativity: we
compare
i == 0 with i == 1
and then
i == 0 || i == 1 with i == 0.
The fix would probably be to keep [low, high] pairs for every comparison and
then compare the pairs.