From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1159 invoked by alias); 28 Apr 2012 12:40:33 -0000 Received: (qmail 1150 invoked by uid 22791); 28 Apr 2012 12:40:33 -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 12:40:20 +0000 From: "marc.glisse at normalesup dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/43772] Errant -Wlogical-op warning when testing limits Date: Sat, 28 Apr 2012 12:40: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: marc.glisse at normalesup dot 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" 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/msg02506.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772 --- Comment #13 from Marc Glisse 2012-04-28 12:40:14 UTC --- (In reply to comment #10) > But there is something strange, because it is warning "it is always false", > which is obviously not true. So I think at some moment it is doing some > transformation we don't want to do. It notices that it should warn, and unless one of the first ranges is trivial (a case it forgot), with an operator &&, the only warning that makes sense is that it is always false. It never shows that it is false, it is just a bit hasty in deciding which warning to pick. And indeed the "logical and...always true" sentence does not exist, because it doesn't make sense. (In reply to comment #11) > (In reply to comment #9) > > It forgets to check first whether the first 2 ranges are trivial. > Or easier, instead of checking: > if (TREE_CODE (tem) != INTEGER_CST) > it could check integer_onep(tem) or integer_zerop(tem) depending on or_op. Or > build a tree integer constant from or_op and tree_int_cst_equal it to tem. Except that this version would warn for xINT_MAX, whereas this belongs to other warnings. So testing the triviality of the first ranges seems best.