Bug 12822 – Delegate .ptr assignment considered @safe
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-30T12:40:00Z
Last change time
2016-10-01T11:47:37Z
Keywords
accepts-invalid, pull, safe
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2014-05-30T12:40:48Z
DMD 2.065 (same for current Git master, 4fbe9f4) accepts the following, obviously unsafe code:
---
class C { int a; int func() { return a; } }
@safe void test() {
auto c = new C();
auto dg = &c.func;
dg.ptr = new long;
dg();
}
---
.ptr/.funcptr cannot be assigned safely, as the type system does not model the context pointer type.