From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 841 invoked by alias); 15 Jun 2011 19:20:05 -0000 Received: (qmail 829 invoked by uid 22791); 15 Jun 2011 19:20:03 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Wed, 15 Jun 2011 19:19:46 +0000 From: "eggert at gnu dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/43772] Errant -Wlogical-op warning when testing limits 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: eggert at gnu 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: CC 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 Date: Wed, 15 Jun 2011 19:20:00 -0000 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: 2011-06/txt/msg01380.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772 eggert at gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |eggert at gnu dot org --- Comment #7 from eggert at gnu dot org 2011-06-15 19:18:57 UTC --- I get the same bug with GCC 4.6.0 (x86-64). Here's a test case: long long emacs_lseek (int fd, long long offset, int whence) { return -1-9223372036854775807LL <= offset && offset <= 9223372036854775807LL; } This is abstracted from real EMACS source code: the real code is verifying that an EMACS_INT value fits within off_t. Both types happen to be 'long long' here, but they might not be the same types on other platforms. When compiled with "gcc -S -Wlogical-op t.c", I get: t.c: In function 'emacs_lseek': t.c:5:3: warning: logical 'and' of mutually exclusive tests is always false [-Wlogical-op] which is obviously bogus. Using "&" rather than "&&" works around the bug, but that's not a satisfactory solution in general.