This is the mail archive of the gcc-patches@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]

Re: integer arithmetic vs alias analysis




--On Friday, August 10, 2001 11:36:37 AM -0700 Richard Henderson 
<rth@redhat.com> wrote:

> On Fri, Aug 10, 2001 at 10:26:39AM -0700, Mark Mitchell wrote:
>> Yes, alias analysis is interesting.  The key argument that I was making
>> is that *pointer arithmetic* is not being used here.  The only operations
>> are casts and *integer arithmetic*.  If pointer arithmetic were being
>> used, then there would be no question that the program had undefined
>> behavior.
>
> I don't think we have to care whether this is pointer or integer
> arithmetic.  Certainly I do not wish to begin caring about it.
>
> The cast opens the "implementation defined" door, and we simply
> say that in our implementation, if you cast from pointer to integer
> then back to pointer, even if there is arithmetic done in between,
> the resulting pointer must refer to the same object as the original.

Yes, I guess we can say that.  That even fits in one sentence, which
is good.  It's unfortunate that this isn't really a "mapping between
integers and pointers" since it depends on how you obtained the
integer, but it's probably the best we can do.

Would you be willing to write that up for the manual?  Probably in
a new chapter on implementation-defined stuff, where we can
gradually fill out Geoff's wish list.

If anyone reading this is on the C committee, it might be worth
raising that issue there as well.

Thanks,

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


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