home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!darwin.sura.net!udel!gvls1!faatcrl!iecc!compilers-sender
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.compilers
- Subject: Re: Adding garbage collection to C++
- Keywords: C, GC, design
- Message-ID: <92-08-112@comp.compilers>
- Date: 19 Aug 92 15:46:52 GMT
- References: <92-08-052@comp.compilers> <92-08-099@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 29
- Approved: compilers@iecc.cambridge.ma.us
-
- 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.
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-