Bug 8353 – Array of polymorphic objects does not compile
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-07-06T13:59:00Z
Last change time
2012-07-07T04:23:26Z
Assigned to
nobody
Creator
jens.k.mueller
Comments
Comment #0 by jens.k.mueller — 2012-07-06T13:59:05Z
A student of ours discovered the following non-compiling code:
class Base { }
class A : Base { }
class B : Base { }
unittest
{
auto c = [ new A, new B ]; // fails to compile but shouldn't A/B be implicitly
// convertible to Base
}
We think the code should compile. c should be an array of Base. As a work around you can add explicit casts to Base.
Comment #1 by yebblies — 2012-07-07T04:23:26Z
*** This issue has been marked as a duplicate of issue 5498 ***