From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25092 invoked by alias); 28 Apr 2012 22:41:14 -0000 Received: (qmail 25080 invoked by uid 22791); 28 Apr 2012 22:41:12 -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 22:40:57 +0000 From: "eggert at gnu dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/43772] Errant -Wlogical-op warning when testing limits Date: Sat, 28 Apr 2012 22:41: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: 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: 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/msg02530.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772 --- Comment #20 from eggert at gnu dot org 2012-04-28 22:40:27 UTC --- (In reply to comment #19) > > intmax_t i = (whatever); > > if (INT_MAX < i && i <= LONG_MAX) > Have you actually seen that? No, I just now invented that example. It was based on experience I've had in using macros like those in gnulib's intprops.h though none of those macros actually have that particular code. >I would imagine the following to be more common: >if(i<=INT_MAX) > print("i is in 'int'"); >else if(i<=LONG_MAX) Yes, intprops.h already has written code that way (instead of using &&) in order to avoid a somewhat-similar bug in the Sun C compiler. There's a comment to that effect in intprops.h. > we are not talking of having this warning by default, > this is an isolated warning not even included in -Wall -Wextra. We can always disable -Wlogical-op when compiling any code that has the problem. It's not a big deal, though it is an annoyance that will prevent people from benefiting from -Wlogical-op. I'm afraid I don't have any magic answers here.