Behavior of "auto"

bearophile bearophileHUGS at lycos.com
Fri Dec 7 02:42:53 PST 2007


Sean Kelly:
> I'd guess that this is a bug, and is related to the extra work the 
> compiler does for foreach loops.

This is a reduced and simplified version that shows the same thing:

class Foo {
    ~this() {
        printf("Destroyed\n");
    }
}

void main() {
    foreach(i; new int[1])
        scope Foo f = new Foo();
}

Bye,
bearophile



More information about the Digitalmars-d mailing list