[Issue 3977] New: Should disable implicit conversion of B[] to A[] when B is derived from A
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 16 14:17:53 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3977
Summary: Should disable implicit conversion of B[] to A[] when
B is derived from A
Product: D
Version: unspecified
Platform: Other
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bugzilla at digitalmars.com
--- Comment #0 from Walter Bright <bugzilla at digitalmars.com> 2010-03-16 14:17:50 PDT ---
This exposes a potential memory corruption problem:
class A {}
class B : A {}
void proc(A[] x, A y) {
x[0] = y;
}
void main() {
B[] anArrayOfB = new B[5];
A a = new A();
proc(anArrayOfB, a);
}
The solution is to disable implicit conversion of B[] to A[], but B[] to
const(A)[] and immutable(B)[] to immutable(A)[] should be allowed.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list