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]

Re: Type based alias analysis


John Milford <jwm@CSUA.Berkeley.EDU> writes:
> [ ... ] nso the compiler would turn this into something
> equivalent to:
> 
> int foo(int *ip, float *fp) {
>   assert(ip != fp);
>   *ip = 10;
>   *fp = 3.4;
>   return(*ip);
> }
> 
> 	Basically, ever time the compiler makes the assumption that
> two pointers don't alias the same memory it would insert a check
> that would verify the assumption is correct at runtime.

Of course, that's not really the extent of the assumption made by the
compiler, right?

A proper check would have to be something like "assert(nooverlap(ip,
fp))", where nooverlap verifies that the memory regions:
	[ (char *)ip .. (char *)ip + sizeof *ip )
	[ (char *)fp .. (char *)fp + sizeof *fp )
do not overlap.


cgd
-- 
Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.


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