How to be Garbage Collector safe.

Kevin Atkinson kevinatk@home.com
Fri Aug 27 17:52:00 GMT 1999


After asking about if gcc is garbage collector safe I got two basic
answers:

Jeffrey A Law <law@cygnus.com> answer was: No, because "I *know* GCC
will create situations which will spoof a garbage collector." However,
Per Bothner <per@bothner.com>, answered with, it is a theoretical
problem, but in practices these hypothetical situations don't come up.

So my question is: What can *I* do as a C++ programmer to make sure the
optimizer doesn't screw with my variables like jeff said.  Would always
having a pointer marked with volatile do the trick such as:

class Y;
class X {
  volatile Y * ptr;
  ...
};

do the trick.  What other things can I do to make sure that I don't have
dangling reference do to premature garbage collections?


-- 
Kevin Atkinson
kevinatk@home.com
http://metalab.unc.edu/kevina/


More information about the Gcc mailing list