This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: m32c: pointer math vs sizetype again
DJ Delorie <dj@redhat.com> writes:
>> Does the following fix it?
>
> Nope, sorry. I was looking at this code in c-common.c, where the expr
> is first created, but I don't know what that ends up calling:
>
> /* Create the sum or difference. */
> if (resultcode == MINUS_EXPR)
> intop = fold_build1 (NEGATE_EXPR, sizetype, intop);
>
> ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop);
>
> It's calling NEGATE on an unsigned type, which seems wrong to me.
NEGATE_EXPR on an unsigned type is fully defined. It's what you
should get when you say "unsigned int i, j; ...; i = - j;".
I think the problem you are facing may be that POINTER_PLUS_EXPR
generally assumes that the right type to use to add to a pointer is
sizetype. You may need to make it use a different type, though I'm
not sure what that type should be in your case.
Ian