poll about delete

bearophile bearophileHUGS at lycos.com
Tue Jul 27 13:46:21 PDT 2010


Andrei Alexandrescu:
> Agreed. I know how to fix it.

Can you tell the idea?

--------

Another thing: currently somewhere in DMD there is some code that tests against returning a scoped object:

class Foo {}
Foo bar() {
    scope Foo f = new Foo;
    return f;
}
void main() {}

That code generates the error:
test.d(4): Error: escaping reference to scope local f

While currently this doesn't generate a compile-time error:

class Foo {}
Foo bar() {
    Foo f = scoped!Foo();
    return f;
}
void main() {}

This bug report shows that 'scoped' can cause other bugs:
http://d.puremagic.com/issues/show_bug.cgi?id=4214

But catching some of the most common bugs is positive, so can the code present in dmd used to catch and avoid the return of a scoped object be used to avoid the return of the library-defined scoped!() object?

Bye,
bearophile


More information about the Digitalmars-d mailing list