From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19955 invoked by alias); 28 Apr 2012 13:08:29 -0000 Received: (qmail 19706 invoked by uid 22791); 28 Apr 2012 13:08:29 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 28 Apr 2012 13:08:16 +0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/43772] Errant -Wlogical-op warning when testing limits Date: Sat, 28 Apr 2012 13:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg02510.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D43772 --- Comment #16 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez 2012-04-28 13:07:41 UTC --- (In reply to comment #15) >=20 > No, there could be a warning that the first test is always false, another= one > that the second one is always false, but adding a third warning that the > conjunction of the 2 is always false seems bogus. This warning is meant f= or: > x<5&&x>10, where each test independently could be true, just not both at = the > same time. I understand now, and I think you are right. We don't have a warning for "((int)x) < INT_MIN" or ((int)x) > INT_MAX but I think it should go to Wtype-limits. Do you think we could test this situation just before the Wlogical-op warni= ng? I can see that some macros may generate x >=3D INT_MIN but the x < INT_MIN = case seems less likely to be intented and we should warn (and then return and av= oid warning with Wlogical-op). I am sure there must be a way to test for "x < MIN_OF_TYPE_OF(x))" and "x > MAX_OF_TYPE_OF(x)" I just haven't investigated how.