[Issue 10830] New: DMD generates two identical version of templated functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 15 14:50:14 PDT 2013


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 at puremagic.com
        ReportedBy: temtaime at gmail.com


--- Comment #0 from Temtaime <temtaime at 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: -------


More information about the Digitalmars-d-bugs mailing list