November 04, 2014 [Issue 13687] New: Virtual call in the interface's precondition is dispatched to the wrong vtbl entry | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13687 Issue ID: 13687 Summary: Virtual call in the interface's precondition is dispatched to the wrong vtbl entry Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: DMD Assignee: nobody@puremagic.com Reporter: acehreli@yahoo.com If an interface makes a virtual function call in its precondition block then the call gets dispatched to the wrong vtbl entry. (Probably to toHash() in the following program). For the bug to occur, the derived class must have a precondition block as well. Also see the following discussion: http://forum.dlang.org/thread/m3bbbb$lgi$1@digitalmars. import std.stdio; interface I { void foo() in { int result = virtualCall(); writeln(result); } int virtualCall(); } class C : I { void foo() in {} body {} int virtualCall() { return 42; } } void main() { new C().foo(); } The output of the program is not the expected 42 from virtualCall(): -226009216 Ali -- |
Copyright © 1999-2021 by the D Language Foundation