[Issue 2894] abstract classes sometimes allow non-abstract bodyless functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 25 06:35:51 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2894


smjg at iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com
           Keywords|wrong-code                  |link-failure, spec




------- Comment #1 from smjg at iname.com  2009-04-25 08:36 -------
That the first example links is understandable - because C.foo is never used,
the compiler doesn't create any references to it.

That the second example fails is semi-understandable - presumably the compiler
creates a vtbl for C's implementation of I, but the linker cannot resolve it
because no implementation of C.foo() has been linked in.  However, it does seem
that DMD could be better at DCE.

Less understandable is that this fails with the same error:
----------
abstract class C { void foo(); }
class D : C {}
void main() { }
----------

It was my understanding as well that a function in an abstract class is
automatically abstract if no body is given.  But it appears now that it's the
same as in a non-abstract - if the function isn't declared abstract, it
references an externally-defined function.  Still, the spec probably needs to
be clearer on the issue.


-- 



More information about the Digitalmars-d-bugs mailing list