[Issue 18744] New: Class l-values can be implicitly converted to `Object` l-values, even in safe code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Apr 7 22:01:04 UTC 2018
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 at puremagic.com
Reporter: code at 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.
--
More information about the Digitalmars-d-bugs
mailing list