[Issue 3655] Virtual functions without bodies are not optimized away.

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3655

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|2.035   |D2

--


[Issue 3655] Virtual functions without bodies are not optimized away.

2009-12-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3655



--- Comment #2 from Eldar Insafutdinov e.insafutdi...@gmail.com 2009-12-27 
05:03:55 PST ---
Ok, actually I am wrong here, final methods are not optimized away - they just
don't exist. And if nobody uses them - you are safe. But the similar behavior
should be present for virtual functions as well I believe - virtual function
without a body should not be present in vtable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3655] Virtual functions without bodies are not optimized away.

2009-12-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3655



--- Comment #1 from Eldar Insafutdinov e.insafutdi...@gmail.com 2009-12-27 
04:13:25 PST ---
(In reply to comment #0)
 This is compiled fine, as final method without a body is optimized away:
 
 class Boo
 {
 final void foo();
 }
 

Of course it is optimized away if it is not used.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3655] Virtual functions without bodies are not optimized away.

2009-12-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3655


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||INVALID


--- Comment #3 from Walter Bright bugzi...@digitalmars.com 2009-12-28 
21:14:32 PST ---
The compiler is working as designed.

The final function is not virtual, so it is never needed in the vtbl[]. Hence,
there is no undefined reference to it in the vtbl[].

The non-final function is virtual, and so a reference to it is put into the
vtbl[]. The function's implementation must exist somewhere, and if it did, the
linker would put a reference to the implementation in the vtbl[]. This feature
allows one to have an implementation that is hidden from the user of the class.

If you truly do not want to implement the function, declare it as 'abstract'.
Then, a NULL is put in the corresponding place in the vtbl[].

Not a bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---