Bug 4834 – Implicit sharing via delegates in std.concurrency
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-09-06T19:26:00Z
Last change time
2010-09-07T16:07:02Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
dsimcha
Comments
Comment #0 by dsimcha — 2010-09-06T19:26:07Z
The following code compiles and should not, because it allows implicit sharing of data between threads in the supposedly safe std.concurrency:
import std.concurrency;
void runDelegate(void delegate() dg) {
dg();
}
class Foo {
uint num;
void incNum() {
num++;
}
}
void main() {
auto foo = new Foo;
spawn(&runDelegate, &foo.incNum);
}