Thread overview | ||||||
---|---|---|---|---|---|---|
|
March 21, 2013 [Issue 9777] New: Calling final interface method leads to wrong code | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9777 Summary: Calling final interface method leads to wrong code Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: johannespfau@gmail.com --- Comment #0 from Johannes Pfau <johannespfau@gmail.com> 2013-03-21 08:21:43 PDT --- Test case: ---- import core.stdc.stdio; interface Timer { final int run() { printf("Timer.run()\n"); fun(); return 1; }; int fun(); } interface Application { final int run() { printf("Application.run()\n"); fun(); return 2; }; int fun(); } class TimedApp : Timer, Application { int fun() { printf("TimedApp.fun()\n"); return 0; } } void main() { auto app = new TimedApp; (cast(Application)app).run(); (cast(Timer)app).run(); app.Application.run(); //fun not called app.Timer.run(); //fun not called } --- Note how "TimedApp.fun()" is not called when using app.Interface.fun. The reason is that the wrong this pointer is passed to the interface functions. For more information see http://forum.dlang.org/post/ki4gfp$295t$1@digitalmars.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 21, 2013 [Issue 9777] Calling final interface method leads to wrong code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | http://d.puremagic.com/issues/show_bug.cgi?id=9777 --- Comment #1 from Johannes Pfau <johannespfau@gmail.com> 2013-03-21 08:29:24 PDT --- https://github.com/D-Programming-Language/dmd/pull/1781 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 22, 2013 [Issue 9777] Calling final interface method leads to wrong code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | http://d.puremagic.com/issues/show_bug.cgi?id=9777 --- Comment #2 from github-bugzilla@puremagic.com 2013-03-21 22:35:49 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f35c753d3d34f14473ec34570a0693ee00f805f0 Fix issue 9777 Wrong code when calling final interface methods Can't use DotTypeExp when converting to the interface as the pointer needs to be adjusted. Use CastExp instead. https://github.com/D-Programming-Language/dmd/commit/1375dee59cdc795ce489985ece034fbbc75f353e Merge pull request #1781 from jpf91/fix9777 Fix issue 9777 Wrong code when calling final interface methods -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 22, 2013 [Issue 9777] Calling final interface method leads to wrong code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | http://d.puremagic.com/issues/show_bug.cgi?id=9777 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Version|D2 |D1 & D2 Resolution| |FIXED -- 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