[Issue 2326] New: Methods within final class are not considered final when optimizing

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 1 11:46:44 PDT 2008


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

           Summary: Methods within final class are not considered final when
                    optimizing
           Product: D
           Version: 1.034
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: matti.niemenmaa+dbugzilla at iki.fi


final class A {
        int i;
              void f() { ++i; }
        final void g() { ++i; }

        void foo() {
                f();
                g();
        }
}

A snippet from obj2asm on the above, compiled with "dmd -c -O -inline
-release":

_D4asdf1A3fooMFZv       comdat
        assume  CS:_D4asdf1A3fooMFZv
                push    EBX
                mov     EBX,EAX
                mov     ECX,[EBX]
                call    dword ptr 014h[ECX]
                inc     dword ptr 8[EBX]
                pop     EBX
                ret

The call to g is inlined, but the call to f is not. Since class A is final, all
methods within it should be considered final for purposes of optimization;
thus, in this case, both f and g should be inlined.


-- 



More information about the Digitalmars-d-bugs mailing list