From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129732 invoked by alias); 20 Apr 2015 11:07:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 129723 invoked by uid 89); 20 Apr 2015 11:07:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 20 Apr 2015 11:07:57 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3KB7q30030365 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Apr 2015 07:07:52 -0400 Received: from tucnak.zalov.cz (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3KB7oZf029621 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 20 Apr 2015 07:07:51 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id t3KB7cAN009360; Mon, 20 Apr 2015 13:07:40 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id t3KB7Vdf009359; Mon, 20 Apr 2015 13:07:31 +0200 Date: Mon, 20 Apr 2015 11:07:00 -0000 From: Jakub Jelinek To: Kyrill Tkachov Cc: Richard Earnshaw , GCC Patches , Ramana Radhakrishnan , Richard Earnshaw Subject: Re: [PATCH][ARM][cleanup] Use IN_RANGE more often Message-ID: <20150420110731.GF1725@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <552E8221.2080401@arm.com> <553267C3.2030509@foss.arm.com> <5534DCEF.6000305@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5534DCEF.6000305@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg01011.txt.bz2 On Mon, Apr 20, 2015 at 12:03:11PM +0100, Kyrill Tkachov wrote: > The definition and comment on IN_RANGE in system.h is: > /* A macro to determine whether a VALUE lies inclusively within a > certain range without evaluating the VALUE more than once. This > macro won't warn if the VALUE is unsigned and the LOWER bound is > zero, as it would e.g. with "VALUE >= 0 && ...". Note the LOWER > bound *is* evaluated twice, and LOWER must not be greater than > UPPER. However the bounds themselves can be either positive or > negative. */ > #define IN_RANGE(VALUE, LOWER, UPPER) \ > ((unsigned HOST_WIDE_INT) (VALUE) - (unsigned HOST_WIDE_INT) (LOWER) \ > <= (unsigned HOST_WIDE_INT) (UPPER) - (unsigned HOST_WIDE_INT) (LOWER)) > > Since it works on positive or negative bounds, I'd think it would work on > signed numbers, wouldn't it? Of course it does, as long as the types of VALUE, LOWER and UPPER aren't wider integer types than {,un}signed HOST_WIDE_INT. As HWI is always 64-bit now, that just means it wouldn't work for 128-bit integral types that aren't used anywhere in GCC. So, just don't use IN_RANGE for floating point values, that might have surprising effects, otherwise it is safe to use it. Jakub