Bug 2326 – Methods within final class are not considered final when optimizing
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-09-01T13:46:00Z
Last change time
2014-03-01T00:36:47Z
Assigned to
bugzilla
Creator
matti.niemenmaa+dbugzilla
Comments
Comment #0 by matti.niemenmaa+dbugzilla — 2008-09-01T13:46:42Z
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.
Comment #1 by bugzilla — 2008-11-14T22:13:49Z
This only happens on D1.
Comment #2 by 2korden — 2008-11-15T06:41:18Z
(In reply to comment #1)
> This only happens on D1.
>
So? Does this mean that the bug is not considered harmful and thus wont be fixed in D1?
Comment #3 by fraserofthenight — 2008-11-15T08:14:50Z
Yes, I would very much like to see this fixed in D1, especially since it's not a spec change at all.
Comment #4 by torhu — 2008-12-07T06:54:45Z
This is listed in the changelog for 1.037, can anyone confirm that it's fixed?
Comment #5 by matti.niemenmaa+dbugzilla — 2008-12-07T09:11:14Z
Fixed in DMD 1.037. (At least the simple example in the report.)
Comment #6 by matti.niemenmaa+dbugzilla — 2009-09-18T06:13:00Z
*** Issue 1909 has been marked as a duplicate of this issue. ***