www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10830] New: DMD generates two identical version of templated functions

http://d.puremagic.com/issues/show_bug.cgi?id=10830

           Summary: DMD generates two identical version of templated
                    functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: temtaime gmail.com


--- Comment #0 from Temtaime <temtaime gmail.com> 2013-08-15 14:50:12 PDT ---
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.

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