This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][1/n][C] Do not sign-extend sizetypes
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Thu, 7 Jun 2012 13:12:04 -0700
- Subject: Re: [PATCH][1/n][C] Do not sign-extend sizetypes
- References: <alpine.LNX.2.00.1104111621110.810@zhemvz.fhfr.qr>
On Mon, Apr 11, 2011 at 7:25 AM, Richard Guenther <rguenther@suse.de> wrote:
>
> This is another try at making sizetype behavior more consistent with
> other integral types. ?In 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[] = {}) by setting the upper bound of
> the domain to integer_minus_one_node. ?This works by luck only
> as the code later calls build_index_type which happily combines
> (and converts) this with a sizetype zero lower bound. ?Simply
> 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. ?The 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 ?Richard Guenther ?<rguenther@suse.de>
>
> ? ? ? ?* stor-layout.c (layout_type): Compute all array index size operations
> ? ? ? ?in the original type.
> ? ? ? ?(initialize_sizetypes): Add comment.
> ? ? ? ?(set_sizetype): Do not set TREE_TYPE of a TREE_VEC.
>
> ? ? ? ?c-family/
> ? ? ? ?* c-common.c (complete_array_type): Build a range type of
> ? ? ? ?proper type.
>
This caused:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53605
--
H.J.