Bug 10830 – DMD generates two identical version of templated functions

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-15T14:50:12Z
Last change time
2024-12-13T18:10:20Z
Assigned to
No Owner
Creator
Temtaime
Moved to GitHub: dmd#18648 →

Comments

Comment #0 by temtaime — 2013-08-15T14:50:12Z
Lets look at that simple code. void foo(int line = __LINE__)() { debug writeln(`hello, world `, line); else writeln(`hello, world`); } void main() { foo(); foo(); } So we have in the binary two identical versions of code if we compile it with -release -O -inline. If the function is big and have been called from many places, then size of binary can increases extremely. I think it's need to improve frontend a little: check if template parametes not used across the function and then drops it.
Comment #1 by robert.schadek — 2024-12-13T18:10:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18648 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB