This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ping] [4.5/m32c] libstdc++ build crashes emitting debug_info
On Fri, Apr 16, 2010 at 11:42 PM, DJ Delorie <dj@redhat.com> wrote:
>
>> The sizetype operand should always be sign-extended even if it is
>> unsigned.
>
> Really? ?How do you do foo[-1] then?
You do foo + -1U. sizetype is smaller and you zero-extent it
(because sizetype is unsigned if you are not Ada) then you
get foo + 65536, not foo - 1. So you have to sign-extend to make
foo[-1] work.
> Remember - this is a problem *because* sizetype is smaller than a
> pointer, so it matters which way you extend. ?You can't rely on
> type-wrapping to make large unsigned constants work as negatives.
Which is why you need to sign-extend.
Richard.