digitalmars.D.bugs - [Issue 18744] New: Class l-values can be implicitly converted to
- d-bugmail puremagic.com (33/33) Apr 07 2018 https://issues.dlang.org/show_bug.cgi?id=18744
https://issues.dlang.org/show_bug.cgi?id=18744 Issue ID: 18744 Summary: Class l-values can be implicitly converted to `Object` l-values, even in safe code Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: accepts-invalid, safe Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: code klickverbot.at --- safe: class A { int* a; } class B { long b; } // Either of these shouldn't be allowed: void boom1(ref A a, B b) { (cast(Object)a) = b; } void boom2(ref A a, B b) { (true ? a : b) = b; } int main() { A a = new A; B b = new B; boom1(a, b); boom2(a, b); return *a.a; } --- compiles fine on DMD 2.079, but covariance in l-values can't be allowed. This is the same problem often illustrated using containers. --
Apr 07 2018