This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ Garbage Collecter
- To: Brian Beuning <bbeuning at mindspring dot com>
- Subject: Re: C++ Garbage Collecter
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Tue, 24 Aug 1999 21:28:13 -0600
- cc: Kevin Atkinson <kevinatk at home dot com>, gcc at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <37C360C0.46D76D79@mindspring.com>you write:
> That project used the MIPS native compiler (not gcc) which has
> a fairly agressive optimizer. We never had a problem with the
> GC and optimzer not getting along.
But that does not mean you will not run into such problems. As a compiler
junkie, I *know* GCC will create situations which will spoof a garbage
collector.
> There are a couple of coding techniques that can cause trouble.
> 1. Only storing (only) a pointer to an object that is outside the object,
>
> for example
> char * alloc() {
> char * x = (char *) malloc( 100 );
> return x-10;
> }
> then the calling code knows to add 10 before using it. This is highly
> perverse code and not likely to be found in practice, but it would break
> the Boehm GC.
Actually, compilers do this internally sometimes as it allows them to generate
more efficient loop code.
jeff