/* compile with: gcc -Werror -Wlogical-op */
#include <limits.h>
# define BOT INT_MIN
# define TOP INT_MAX
int main(void)
{
int i=42;
i = (i > BOT && i < TOP); //OK
i = (i >= BOT+1 && i <= TOP-1); //OK
i = (i >= BOT && i <= TOP); //Oops!
}
--
Summary: Errant -Wlogical-op warning when testing limits
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: P at draigBrady dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772