From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95479 invoked by alias); 4 Sep 2015 11:02:04 -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 95468 invoked by uid 89); 4 Sep 2015 11:02:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS,UNSUBSCRIBE_BODY 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; Fri, 04 Sep 2015 11:02:03 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 50620550D1 for ; Fri, 4 Sep 2015 11:02:02 +0000 (UTC) Received: from redhat.com (ovpn-204-115.brq.redhat.com [10.40.204.115]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84B1vdA004619 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Fri, 4 Sep 2015 07:02:01 -0400 Date: Fri, 04 Sep 2015 11:03:00 -0000 From: Marek Polacek To: GCC Patches Subject: [PATCH] Tweak INTTYPE_MINIMUM to avoid warning Message-ID: <20150904110156.GA2813@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-09/txt/msg00334.txt.bz2 While looking into something else I spotted this UB. I rewrote this to use another UB, but I'd say left-shifting into the sign bit isn't such an anathema as it was. It's -Wshift-negative-value that warns on this. The reason why we haven't seen the warning before is due to a bug I'm fixing in the other patch. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2015-09-03 Marek Polacek * system.h (INTTYPE_MINIMUM): Rewrite to avoid shift warning. * system.h (INTTYPE_MINIMUM): Rewrite to avoid shift warning. diff --git gcc/gcc/system.h gcc/gcc/system.h index 9ca5b5f..78ad609 100644 --- gcc/gcc/system.h +++ gcc/gcc/system.h @@ -307,7 +307,7 @@ extern int errno; /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. It is necessary at least when t == time_t. */ #define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \ - ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) + ? (t) 1 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t))) /* Use that infrastructure to provide a few constants. */ diff --git gcc/libcpp/system.h gcc/libcpp/system.h index b18d658..a2e8c26 100644 --- gcc/libcpp/system.h +++ gcc/libcpp/system.h @@ -230,7 +230,7 @@ extern int errno; /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. It is necessary at least when t == time_t. */ #define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \ - ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0)) + ? (t) 1 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) #define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t))) /* Use that infrastructure to provide a few constants. */ Marek