www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1758] New: Lazy Parameters in Closures - Access Violation

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1758

           Summary: Lazy Parameters in Closures - Access Violation
           Product: D
           Version: 2.009
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: xnknet gmail.com


The following code will cause an access violation error.

T delegate() lazier(T)(lazy T arg){
        bool once = true;
        T value;
        return {
                if(once){
                        once = false;
                        value = arg;
                }
                return value;
        };
}

void main(){
        auto l = lazier(rand());
        writeln(l()); // Access violation
}


-- 
Jan 01 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1758


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-10-19 08:33:22 PDT ---
This failed in 2.012, but was fixed by 2.020.

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