digitalmars.D.bugs - [Issue 2196] New: Link errors with an abstract class's method implementing an interface
- d-bugmail puremagic.com (32/32) Jul 05 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2196
- d-bugmail puremagic.com (14/14) Jul 06 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2196
- d-bugmail puremagic.com (18/21) Apr 23 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2196
- d-bugmail puremagic.com (12/12) Apr 23 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2196
- d-bugmail puremagic.com (9/9) Jan 26 2013 http://d.puremagic.com/issues/show_bug.cgi?id=2196
http://d.puremagic.com/issues/show_bug.cgi?id=2196 Summary: Link errors with an abstract class's method implementing an interface Product: D Version: 1.031 Platform: PC OS/Version: Linux Status: NEW Keywords: link-failure, spec Severity: minor Priority: P3 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: diggory.hardy gmail.com The following code generates an error at link time: interface A { void foo (); } abstract class B : A { void foo (); } void main() {} The error: abstract.o: In function `_TMP0': abstract.d:(.text+0x4): undefined reference to `_D8abstract1B3fooMFZv' collect2: ld returned 1 exit status Marking foo in B as abstract avoids the problem. The documentation isn't at all clear on whether this should be the case. Tried with dmd 1.031 and 1.027, and gcc (Debian 4.3.1-2) 4.3.1. --
Jul 05 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2196 I'm not sure if it is a bug, this is a correct behaviour to me. In this code: abstract class B : A { void foo (); } you define a method foo() and should provide a function body somewhere. Merely marking class abstract says that you can't instantiate it, but you can any other class that subclasses from it, unless it is abstract, too. If you mark you method as abstract it means that there is no body, child class should provide an implementation. Interface methods are implicitly abstract. --
Jul 06 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2196 gide nwawudu.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALIDI'm not sure if it is a bug, this is a correct behaviour to me. If you mark your method as abstract it means that there is no body, child class should provide an implementation.The following compiles correctly, the original code should not link. interface A { void foo (); } abstract class B : A { abstract void foo (); } void main() {} --
Apr 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2196 diggory.hardy gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED Agreed. I think what I was unsure on is why the linker wanted the definitions of an abstract class that wasn't (attempted to be) used. But of course having to explicitly mark such functions as abstract does make it clear whether or not the function was intended to be defined in that class. --
Apr 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2196 Andrei Alexandrescu <andrei erdani.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|CLOSED |RESOLVED CC| |andrei erdani.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 26 2013