home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / compiler / 1413 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  1.8 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!darwin.sura.net!udel!gvls1!faatcrl!iecc!compilers-sender
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.compilers
  4. Subject: Re: Adding garbage collection to C++
  5. Keywords: C, GC, design
  6. Message-ID: <92-08-112@comp.compilers>
  7. Date: 19 Aug 92 15:46:52 GMT
  8. References: <92-08-052@comp.compilers> <92-08-099@comp.compilers>
  9. Sender: compilers-sender@iecc.cambridge.ma.us
  10. Reply-To: tmb@arolla.idiap.ch (Thomas M. Breuel)
  11. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  12.     Perceptive)
  13. Lines: 29
  14. Approved: compilers@iecc.cambridge.ma.us
  15.  
  16. fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  17.  
  18.    >[you can detect and remember any pointer that is hidden by type punning,
  19.    >writing to files, etc.]
  20.  
  21.    This may be true in theory, but it seems like it would be very difficult
  22.    in practice (especially if you allow separate compilation) and might lead
  23.    to memory leaks.
  24.  
  25.    Presumably you have to consider every conversion from (T **) to (void *)
  26.    potentially dangerous, since the (void *) could be used to hide away the
  27.    (T *) pointer, using memcpy(), fwrite(), or some such.  But such
  28.    conversions may be relatively common.
  29.  
  30. As I said before, I don't advocate this scheme. It's a cute solution to an
  31. interesting puzzle, nothing more.
  32.  
  33. In practice, a C/C++ standard with GC should state that if you intend to
  34. scramble the bits of a pointer, you better keep an unscrambled version of
  35. the pointer around somewhere for the GC to find.
  36.  
  37. I don't think this would affect many programs, and the ones that would be
  38. affected by it could simply be run with the GC turned off (since they were
  39. presumably written before GC was added to the language).
  40.  
  41.                     Thomas.
  42. -- 
  43. Send compilers articles to compilers@iecc.cambridge.ma.us or
  44. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  45.