digitalmars.D.bugs - [Issue 8306] New: alias 'array' this consumes array on iteration
- d-bugmail puremagic.com (51/51) Jun 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8306
- d-bugmail puremagic.com (15/15) Jun 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8306
- d-bugmail puremagic.com (11/11) Jul 01 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8306
http://d.puremagic.com/issues/show_bug.cgi?id=8306 Summary: alias 'array' this consumes array on iteration Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: tobias pankrath.net --- Comment #0 from Tobias Pankrath <tobias pankrath.net> 2012-06-27 01:05:37 PDT --- Created an attachment (id=1121) code showing the bug The attached program produces buggy code. This code stores an index (a list of Agg*) to some Agg and prints all Agg currently in this index. Then it prints every Agg in turn. In the foreach loop every agg is empty. Which is wrong. It works however, if I comment out the alias content this; line or if I don't print the index before the loop. struct A { int a; int b; } struct Agg { A[] content; alias content this; } void main(string[] args) { Agg* agg = new Agg; A l1 = A((1), (2)); A l2 = A((2), (3)); A l3 = A((3), (4)); agg.content ~= [l1, l2, l3]; Agg*[] aggIndex = [agg]; writefln("these are the %s aggregates:\n%s", aggIndex.length, aggIndex); foreach(Agg* myAgg; aggIndex) { A[] as = (*myAgg).content; writefln("current agg %s with length %s", as, as.length); } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 27 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8306 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg gmx.com --- Comment #1 from Jonathan M Davis <jmdavisProg gmx.com> 2012-06-27 01:29:29 PDT --- On the latest master, I get the exact same behavior regardless of whether the alias is there. I always get these are the 1 aggregates: [7F3AB1ECEFF0] current agg [A(1, 2), A(2, 3), A(3, 4)] with length 3 and commenting out the first print statement has no effect on the second. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 27 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8306 Tobias Pankrath <tobias pankrath.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WORKSFORME --- Comment #2 from Tobias Pankrath <tobias pankrath.net> 2012-07-01 01:32:02 PDT --- Can not reproduce with git master, too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2012