From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24398 invoked by alias); 7 Jun 2012 20:12:23 -0000 Received: (qmail 24364 invoked by uid 22791); 7 Jun 2012 20:12:18 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-qa0-f50.google.com (HELO mail-qa0-f50.google.com) (209.85.216.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Jun 2012 20:12:05 +0000 Received: by qafl39 with SMTP id l39so457630qaf.9 for ; Thu, 07 Jun 2012 13:12:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.102.73 with SMTP id f9mr1203363qco.103.1339099924120; Thu, 07 Jun 2012 13:12:04 -0700 (PDT) Received: by 10.229.192.129 with HTTP; Thu, 7 Jun 2012 13:12:04 -0700 (PDT) In-Reply-To: References: Date: Thu, 07 Jun 2012 20:18:00 -0000 Message-ID: Subject: Re: [PATCH][1/n][C] Do not sign-extend sizetypes From: "H.J. Lu" To: Richard Guenther Cc: gcc-patches@gcc.gnu.org, "Joseph S. Myers" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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 X-SW-Source: 2012-06/txt/msg00469.txt.bz2 On Mon, Apr 11, 2011 at 7:25 AM, Richard Guenther wrote: > > This is another try at making sizetype behavior more consistent with > other integral types. =A0In particular this series will eventually > succeed in making TYPE_UNSIGNED tell the truth for sizetypes ... > > This first patch replaces a hack in the C frontend to handle > zero-sized arrays (int a[] =3D {}) by setting the upper bound of > the domain to integer_minus_one_node. =A0This works by luck only > as the code later calls build_index_type which happily combines > (and converts) this with a sizetype zero lower bound. =A0Simply > using an integer typed domain fixes this, so the patch makes > the C frontend use build_range_type instead. > > Similarly the stor-layout.c code fails to properly use > signed arithmetic when it needs to. =A0The present code presumably > already handles some cases, but not that special case of > adding one to -1. > > The rest of the patch is simple stuff I noticed when going over > the code. > > Bootstrapped and tested on x86_64-unknown-linux-gnu for all > languages including Ada and Objective-C++. > > Are the c-family changes ok? > > Thanks, > Richard. > > 2011-04-11 =A0Richard Guenther =A0 > > =A0 =A0 =A0 =A0* stor-layout.c (layout_type): Compute all array index siz= e operations > =A0 =A0 =A0 =A0in the original type. > =A0 =A0 =A0 =A0(initialize_sizetypes): Add comment. > =A0 =A0 =A0 =A0(set_sizetype): Do not set TREE_TYPE of a TREE_VEC. > > =A0 =A0 =A0 =A0c-family/ > =A0 =A0 =A0 =A0* c-common.c (complete_array_type): Build a range type of > =A0 =A0 =A0 =A0proper type. > This caused: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53605 --=20 H.J.