Bug or Feature?

Max Samuha maxter at i.com.ua_spamless
Tue Jun 13 23:37:57 PDT 2006


On Tue, 13 Jun 2006 21:56:40 +0000 (UTC), leoandru
<leoandru_member at pathlink.com> wrote:

><code>
>interface Foo
>{
>Object clone();
>}
>
>class Bar : Foo
>{
>Bar clone()
>{
>return this; 
>}
>
>}
>
>void main()
>{
>Bar b = new Bar();
>Bar c = b.clone(); //works fine
>
>Foo f = b;
>Foo g = f.clone(); //access violation

Threre should be a cast to Foo: Foo g = cast(Foo)f.clone(). The code
works well for me (WinXP, D 0.160). 

>}
></code>

Do you get access violation or AssertError? If it's AssertError, you
might forget to put 'return' in a function that requirs a value to be
returned (int main(...){return 0;}?). D doesn't warn about missing
returns at compile time.




More information about the Digitalmars-d mailing list