Bug 1359 – Can call non implemented functions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2007-07-20T18:15:00Z
Last change time
2014-02-16T15:21:25Z
Keywords
accepts-invalid, wrong-code
Assigned to
nobody
Creator
moritzwarning
Blocks
340

Attachments

IDFilenameSummaryContent-TypeSize
169Test3.dalternative testcasetext/plain1667

Comments

Comment #0 by moritzwarning — 2007-07-20T18:15:01Z
In this following example we can call Foo.get even it is not implemented. The program compiles and runs without problems, but shouldn't. When Foo.get is implemented it also never get called. The compiler recognizes the bug when the return type for get isn't a template or interfaces Node and Nodes changes places. module Main; class Bar(T) { } //program compiles but crashes when interface is empty interface Node : Nodes { void print(); } interface Nodes { public: Bar!(Node) get(); } class Foo : Node { public: void print() { } /* //never get called when implemented Bar!(Node) get() { return null; } */ } void main(char[][] args) { Node foo = new Foo; foo.get(); }
Comment #1 by moritzwarning — 2007-08-11T08:45:32Z
Created attachment 169 alternative testcase This is another testcase that show that applications can silently change behavior ,crash or just don't work only by switching the order of declaration of two interfaces. It doesn't matter if the interfaces are defined in another file.
Comment #2 by r.sagitario — 2009-09-18T01:45:16Z
Seems to work fine with DMD 1.047 and DMD 2.032. I haven't tested the additional alternative testcase, though (because of the tango usage).
Comment #3 by clugdbug — 2009-09-18T15:12:08Z
Fixed in 1.029 or 1.030.