Path: utzoo!censor!dybbuk!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!ucsd!ucbvax!agate!darkstar!terra.ucsc.edu!daniel From: daniel@terra.ucsc.edu (Daniel Edelson) Newsgroups: comp.lang.c++ Subject: Smart Pointers Aren't Enough Keywords: garbage collection, smart pointers, frustration Message-ID: <11707@darkstar.ucsc.edu> Date: 30 Jan 91 17:37:25 GMT Article-I.D.: darkstar.11707 Sender: usenet@darkstar.ucsc.edu Reply-To: daniel@terra.ucsc.edu (Daniel Edelson) Organization: University of California, Santa Cruz Lines: 31 Even if we had a ``perfect'' implementation of smart pointers, I don't think that would be enough to permit robust copying garbage collection. Unfortunately. By perfect I mean that all of the application's pointers of type (node *) were smart pointers rather than raw pointers. Perhaps I'm using the word perfect in a misleading way. If so, I hope someone will clairify. Case in point: struct node { int i; }; int * foo() { smart_pointer_to_node p = new node; int * i = &p->i; return i; } How do we keep the node from being collected now that the smart pointer to it has been destroyed? What's the best course of action here? Forbid taking the address of members of a collected object? I already place so many restrictions on code that uses my garbage collector that this seems unattractive. I am not a proponent of conservative garbage collection, but the more I examine these problems the more I lean that way. Daniel Edelson daniel@cis.ucsc.edu