Bug 85 – Array of classes doesn't function as array of interfaces
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-04-04T11:05:00Z
Last change time
2014-02-15T02:10:12Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
matti.niemenmaa+dbugzilla
Comments
Comment #0 by matti.niemenmaa+dbugzilla — 2006-04-04T11:05:34Z
Testcase below - originally posted as a comment in Bug 65.
Note that while this can be worked around simply by changing the Class[] to I[], the code as it is below generates an incorrect program.
------------------
interface I {
I[] foo();
uint x();
}
class Class : I {
I[] foo() {
// changing this to I[] f = new Class[1] fixes the bug
Class[] f = new Class[1];
f[0] = new Class;
return f;
}
uint x() {
return 0;
}
}
void main() {
Class c = new Class();
assert (c.x == 0);
assert (c.foo[0].x == 0);
}
------------------
Comment #1 by thomas-dloop — 2006-04-06T02:25:18Z
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email protected] schrieb am 2006-04-04:
> Testcase below - originally posted as a comment in Bug 65.
>
> Note that while this can be worked around simply by changing the Class[] to
> I[], the code as it is below generates an incorrect program.
>
> ------------------
> interface I {
> I[] foo();
> uint x();
> }
>
> class Class : I {
> I[] foo() {
> // changing this to I[] f = new Class[1] fixes the bug
> Class[] f = new Class[1];
> f[0] = new Class;
> return f;
> }
>
> uint x() {
> return 0;
> }
> }
>
> void main() {
> Class c = new Class();
> assert (c.x == 0);
> assert (c.foo[0].x == 0);
> }
> ------------------
Added to DStress as
http://dstress.kuehne.cn/run/i/interface_24_A.dhttp://dstress.kuehne.cn/run/i/interface_24_B.dhttp://dstress.kuehne.cn/run/i/interface_24_C.dhttp://dstress.kuehne.cn/run/i/interface_24_D.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFENMm33w+/yD4P9tIRAlC3AJ9QVGQPHBKByi84so9CUlefOXz+LwCgw+Bw
GPcAGQaUavOJYIyT6E6JiR8=
=5NI1
-----END PGP SIGNATURE-----