This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [m32c] type precedence rules and pointer signs


On Jan 31, 2008 9:26 PM, DJ Delorie <dj@redhat.com> wrote:
>
> > It's correct to always sign-extend the offset to the pointer mode
> > width (or simply truncate it, if the offset width is larger than
> > pointer mode width).
>
> I'd argue against that if you're dereferencing a large structure
> pointer.  P->foo would always be an unsigned offset.  Similarly for
> arrays, although one could argue either way with that.

You cannot tell the unsigned case apart from the signed case and
structure dereferences are using COMPONENT_REF, not POINTER_PLUS_EXPR.

The middle-end assumes that the offset part of POINTER_PLUS_EXPR is
signed, so to extend it this way during expansion would be the natural
thing to do.

> In the m32c case, though, the offset is a signed type, but an unsigned
> extension was used.  The mismatch is the problem.

Yes, but sizetype is unsigned (but sign-extended - which is appearantly not
enforced at expansion here).

> Either way, there's going to be a compromise.

I don't think it's a compromise - it's just a bugfix ;)

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]