Are there any default dmd optimizations

Timon Gehr timon.gehr at gmx.ch
Thu Feb 28 15:07:08 PST 2013


On 03/01/2013 12:01 AM, Walter Bright wrote:
> On 2/28/2013 11:03 AM, Timon Gehr wrote:
>> It's really easy. DMD can be convinced to do a sufficient[ly] conservative
>> analysis
>> even now, but the behaviour is undocumented and seems unintentional.
>>
>>
>>      void main() {
>>          void foo()() { bar(); }
>>          void bar()() { i = 3; }
>>          int i;
>>          foo();
>>      }
>
> No, the compiler is not being clever here,

I wasn't stating that.

> nor is this undocumented.

Where is it documented?

> Templates are not semantically analyzed until they are instantiated.  In
> fact, they can't be semantically analyzed until they are instantiated.
>

Obviously. In the above code all templates are instantiated. This is 
about which state of the function local symbol table is used.


More information about the Digitalmars-d mailing list