aa.remove in a destructor

Ellery Newcomer ellery-newcomer at utulsa.edu
Sat Jun 23 21:15:52 PDT 2012


this code:

class X{
     string[string] s;
     this() {
         s["s"] = "S";
     }
     ~this() {
         s.remove("s");

     }
}

void main() {
     X x = new X();
}

produces this:

core.exception.InvalidMemoryOperationError

because the aa is calling gc_free during a collection, apparently.

Should I be expecting the above code to run without error or not?

thanks


More information about the Digitalmars-d-learn mailing list