http://d.puremagic.com/issues/show_bug.cgi?id=10970
--- Comment #8 from Zhouxuan <[email protected]> 2013-09-06 07:22:25 PDT --- (In reply to comment #6) > (In reply to comment #5) > > Crashes on win32 as well. > > If I recall correctly, I think the problem is "simply" that AA has *very* bad > support for types with elaborate CC, and destruction. Take this "simple" use > case: > > //#### > import std.stdio; > > int count; > > struct S > { > this(int){++count; writeln("construction");} > this(this){assert(0);} //never called > ~this(){--count; writeln("destruction");} > } > > void main() > { > S[int] aa; > writeln("----"); > aa[5] = S(3); > writeln("----"); > aa.remove(5); > writeln("----"); > assert(aa.length == 0); > assert(count >= 0); //Fails here > } > //#### > ---- > construction > destruction > destruction > ---- > ---- > //#### > > In just this little snippet, there are *all* kinds of wrong: > 1. insertion: when inserting a new item, CC ("this(this)") is never called for > some strange reason. Furthermore, destruction happens *twice* (again, for some > strange reason). > 2. removal: Where's the destructor? > > These use cases are probably reported already, you are experiencing the > results > of these defects. > > Long story short, at the end of the day, your array is "over-destroyed". Given > that AA is a *strongly* relies on reference counting to provide deterministic > behavior, things simply don't go well. > > A lot of work is being done on fixing AAs (AFAIK), but don't expect it to be > fixed any time soon. > > As a workaround, you could try using slices instead of AA's? > > //---- > import std.stdio; > > class A > { > this(string name) > { > m[name] = Arr.init; > } > > alias A[] Arr; > Arr[string] m; > } > > int main() > { > A a = new A("test"); > return 0; > } > //---- > > In particular, "A" is a class, so it can't have a destructor (in the sense > that > a *reference* doesn't get destroyed). As such, there is minimal use to keeping > an Array over a slice. Thank you, I can work around it by changing the design, however, this really need to be fixed in the near future! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
