This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ Garbage Collecter
- To: Per Bothner <per@bothner.com>
- Subject: Re: C++ Garbage Collecter
- From: Jeffrey A Law <law@cygnus.com>
- Date: Thu, 26 Aug 1999 01:59:47 -0600
- cc: gcc@gcc.gnu.org
- Reply-To: law@cygnus.com
In message <m2btbw30qj.fsf@magnus.bothner.com>you write:
> I don't think these statements are very relevant. Yes, the compiler
> sometimes does such re-writing, but that is not a problem for a
conservative
> collectors as long as there is still a pointer somewhere that points to
> the actual base of the object. And either you have a newly allocated
> object that will be passed to someone, or it was an existing object
> that was passed from somewhere (as an argument). In either case, you
> would have a pointer to the base object somewhere.
But this is precisely the problem. You allocate a hunk of memory and initially
assign it to some variable. Let's call it "a".
You then do a lot of indexing off "a" in a loop. The compiler may create a
pointer outside of "a" and kill the pseudo which originally contained "a".
If you do garbage collection you lose.
ie, the compiler effectively does something like this:
a = malloc (100)
a -= 10
for ( ... )
a[10 + i] = whatever
even though you wrote
a = malloc (100)
for ( ...)
a[i] = whatever
jeff