digitalmars.D - If I'm not being retarded than I might have found a bug or something
- Joey Peters (20/20) Aug 24 2004 private import std.stream;
- Andy Friesen (8/30) Aug 25 2004 This is a pretty well known problem with garbage collection. When the
private import std.stream; class foo { public: // Also streams etc File bar; this(char[] fn) { bar = new File(fn); } ~this() { bar.close(); } } int main(char[][] args) { // errors on runtime foo gen = new foo("thisfile.d"); // runs File bar; bar = new File("thisfile.d"); return 0; }
Aug 24 2004
Joey Peters wrote:private import std.stream; class foo { public: // Also streams etc File bar; this(char[] fn) { bar = new File(fn); } ~this() { bar.close(); } } int main(char[][] args) { // errors on runtime foo gen = new foo("thisfile.d"); // runs File bar; bar = new File("thisfile.d"); return 0; }This is a pretty well known problem with garbage collection. When the program terminates, everything has to be destroyed, but it isn't always possible to destroy everything in the correct order, (a correct order may not even exist in the case of circular references) so destructors that access other objects inevitably run the risk of having a reference to a destroyed object. -- andy
Aug 25 2004