Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 05, 2008 [Issue 2196] New: Link errors with an abstract class's method implementing an interface | ||||
---|---|---|---|---|
| ||||
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. -- |
July 06, 2008 [Issue 2196] Link errors with an abstract class's method implementing an interface | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2196 ------- Comment #1 from 2korden@gmail.com 2008-07-06 05:09 ------- 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. -- |
April 23, 2009 [Issue 2196] Link errors with an abstract class's method implementing an interface | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2196 gide@nwawudu.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #2 from gide@nwawudu.com 2009-04-23 05:12 ------- (In reply to comment #1) > I'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() {} -- |
April 23, 2009 [Issue 2196] Link errors with an abstract class's method implementing an interface | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2196 diggory.hardy@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED ------- Comment #3 from diggory.hardy@gmail.com 2009-04-23 08:22 ------- 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. -- |
January 26, 2013 [Issue 2196] Link errors with an abstract class's method implementing an interface | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
Copyright © 1999-2021 by the D Language Foundation