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

           Summary: Disallow escaping of references to stack-allocated
                    memory
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-02-07 13:05:29 PST ---
This is D2 code:


struct Foo {
    int x;
}
Foo* bar() {
    Foo f = Foo(1);
    return &f;
}
void main() {}


DMD 2.051 raises a compile-time error:
test.d(6): Error: escaping reference to local f


But this code compiles and runs with no errors with DMD 2.051. I think DMD has
to statically disallow code like this too:


struct Foo {
    int x;
}
Foo* bar() {
    return &(Foo(1));
}
void main() {}

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

Reply via email to