Bug 8526 – DMD 2.060 regression: anonymous delegate call in foreach loop

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-09T00:34:00Z
Last change time
2012-11-09T05:48:40Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2012-08-09T00:34:53Z
void call(void delegate() callback) { callback(); } void f(int j, int i) { } void main() { foreach (int i, j; [0]) call({ f(j, i); }); } Works on 2.059, segfaults on 2.060. Tested on Win32 and Linux/64.
Comment #1 by nazriel6969 — 2012-09-05T01:52:43Z
Works with DMD 1.075 Looks like it is D2 only. DMD2.060 fails both with m32/m64, on Linux and FreeBSD Current DMD2 trunk still has this bug.
Comment #2 by k.hara.pg — 2012-11-08T19:43:00Z
*** Issue 8775 has been marked as a duplicate of this issue. ***
Comment #3 by k.hara.pg — 2012-11-08T19:45:42Z
From bug 8775, foreach range statement has same bug. void call(void delegate() dg) { dg(); } void main() { foreach (i, j; [0]) { call({ assert(i == 0); // fails, i is corrupted }); } foreach (n; 0..1) { call({ assert(n == 0); // fails, n is corrupted }); } }
Comment #4 by k.hara.pg — 2012-11-08T21:15:15Z
*** Issue 8974 has been marked as a duplicate of this issue. ***
Comment #5 by k.hara.pg — 2012-11-09T02:17:24Z
Comment #6 by github-bugzilla — 2012-11-09T04:15:57Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/251a8bb0ede5e45bf5f41b60554a2962261516ff fix Issue 8526 - DMD 2.060 regression: anonymous delegate call in foreach loop This regression has occured from the commit: https://github.com/D-Programming-Language/dmd/commit/38a0a5141a3455395e8b9571a57bf85ed698c6b3 But the root cause is a bug in glue layer. When an internal ref variable is marked as closure var, the glue layer had generated incorrect code for that. https://github.com/D-Programming-Language/dmd/commit/8fc3e4b59bf5786accee257d301ca8de8cf8a277 Merge pull request #1272 from 9rnsr/fix8526 Issue 8526 & 6141 - DMD 2.060 regression: anonymous delegate call in foreach loop