Can the D compiler detect final and optimize?

rikki cattermole rikki at cattermole.co.nz
Fri Mar 13 15:15:50 UTC 2020


Why would this be needed?

With ldc -O3 the test function can be completely erased:

import std;
void main()
{
     Foo foo = new Foo;
     foo.x = 7;
     test(foo);
}

void test(Foo foo) {
     writeln(foo.get);
}

class Foo {
     int x;

     int get() { return x; }
}


More information about the Digitalmars-d mailing list