Re: Adding garbage collection to C++

tmb@arolla.idiap.ch (Thomas M. Breuel)
Wed, 19 Aug 1992 15:46:52 GMT

          From comp.compilers

Related articles
[8 earlier articles]
Re: Adding garbage collection to C++ pardo@cs.washington.edu (1992-08-15)
Re: Adding garbage collection to C++ tmb@idiap.ch (1992-08-17)
Re: Adding garbage collection to C++ tmb@idiap.ch (1992-08-17)
Re: Adding garbage collection to C++ hudson@cs.umass.edu (1992-08-17)
Re: Adding garbage collection to C++ fjh@munta.cs.mu.OZ.AU (1992-08-18)
Re: Adding garbage collection to C++ tmb@arolla.idiap.ch (1992-08-18)
Re: Adding garbage collection to C++ tmb@arolla.idiap.ch (1992-08-19)
Re: Adding garbage collection to C++ maxtal@extro.ucc.su.OZ.AU (1992-08-20)
Re: Adding garbage collection to C++ fjh@munta.cs.mu.OZ.AU (1992-08-21)
| List of all articles for this month |
Newsgroups: comp.compilers
From: tmb@arolla.idiap.ch (Thomas M. Breuel)
Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle Perceptive)
Date: Wed, 19 Aug 1992 15:46:52 GMT
References: 92-08-052 92-08-099
Keywords: C, GC, design

fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:


      >[you can detect and remember any pointer that is hidden by type punning,
      >writing to files, etc.]


      This may be true in theory, but it seems like it would be very difficult
      in practice (especially if you allow separate compilation) and might lead
      to memory leaks.


      Presumably you have to consider every conversion from (T **) to (void *)
      potentially dangerous, since the (void *) could be used to hide away the
      (T *) pointer, using memcpy(), fwrite(), or some such. But such
      conversions may be relatively common.


As I said before, I don't advocate this scheme. It's a cute solution to an
interesting puzzle, nothing more.


In practice, a C/C++ standard with GC should state that if you intend to
scramble the bits of a pointer, you better keep an unscrambled version of
the pointer around somewhere for the GC to find.


I don't think this would affect many programs, and the ones that would be
affected by it could simply be run with the GC turned off (since they were
presumably written before GC was added to the language).


Thomas.
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.