Bug 1758 – Lazy Parameters in Closures - Access Violation
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-01-01T10:42:00Z
Last change time
2015-06-09T01:14:26Z
Keywords
wrong-code
Assigned to
nobody
Creator
xinok
Comments
Comment #0 by xinok — 2008-01-01T10:42:06Z
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
}