[Issue 6141] Bad code with ref-foreach and closures

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 22 06:20:40 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6141


Denis <verylonglogin.reg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg at gmail.com


--- Comment #2 from Denis <verylonglogin.reg at gmail.com> 2012-04-22 17:21:39 MSD ---
Looks like the same issue:
---
void main() {
    foreach(ref val; [3]) {
        auto del = { int j = val; };
        assert(&val != null); // Assertion failure
        assert(val == 3);
    }
}
---
and
---
void f(lazy int) { }

void main() {
    int i = 0;
    auto del = { int j = i; };

    foreach(ref val; [3]) {
        f(val);
        assert(&val != null); // Assertion failure
        assert(val == 3);
    }
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list