Bug 15912 – Anonymous class with missing method results in linker error

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-04-11T01:43:00Z
Last change time
2016-04-11T04:58:52Z
Assigned to
nobody
Creator
andy.pj.hanson

Comments

Comment #0 by andy.pj.hanson — 2016-04-11T01:43:24Z
This code successfully compiles, but fails to link: abstract class A { void x(); } void main() { new class A {}; } The error is: app.o:(.data._D3app4mainFZ13__anonclass516__vtblZ+0x28): undefined reference to `_D3app1A1xMFZv' The error message doesn't mention what causes the error, so it would be nice to detect these problems at compile-time. This might be related to issue 13438.
Comment #1 by ag0aep6g — 2016-04-11T04:58:52Z
(In reply to andy.pj.hanson from comment #0) > This code successfully compiles, but fails to link: > > abstract class A { > void x(); > } > > void main() { > new class A {}; > } The same happens with a named class (undefined reference to A.x): ---- abstract class A {void x();} class B : A {} void main() {new B;} ---- This is expected. x is not abstract here. It's supposed to be implemented externally. To make it a compile error, make x abstract: ---- abstract class A { abstract void x(); } void main() { new class A {}; /* Error: cannot create instance of abstract class __anonclass1 */ } ---- Closing as invalid. Feel free to reopen if you think I'm missing something.