On 22/12/2010 18:17, bearophile wrote:
A little D2 program:

void main() {
            pure nothrow int foo1(immutable int x) { return x; }
     static pure nothrow int foo2(immutable int x) { return x; }
}


This is the asm of the two inner functions:

_D6test4mainFZv4foo1MFNaNbyiZi    comdat
         enter   4,0
         mov EAX,8[EBP]
         leave
         ret 4

_D6test4mainFZv4foo2FNaNbyiZi comdat
         enter   4,0
         leave
         ret

Is this a compiler mistake? Aren't strongly pure inner function static too?

Bye,
bearophile

Why would they be?

Surely a pure inner function could access immutable vars from the outer function and still be pure.

That's being said, you'd hope the compiler would recognise that foo1 is essentially static and optimise it properly.

--
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk

Reply via email to