Compiler does some flow analysis with -O..?

Denis Koroskin 2korden at gmail.com
Thu Apr 9 08:08:22 PDT 2009


On Thu, 09 Apr 2009 18:53:07 +0400, Jarrett Billingsley <jarrett.billingsley at gmail.com> wrote:

> On Thu, Apr 9, 2009 at 10:28 AM, Denis Koroskin <2korden at gmail.com>  
> wrote:
>
>> I believe this is just an optimization and not a general-purpose flow
>> analysis:
>
> It happens even with a non-trivial condition.

Now I am convinced:

extern(C) int rand();

void main()
{
    int x = void;
    if (rand() == 0) {
        x += 5; 		// line 7
    }
}

test.d(7): Error: variable x used before set

It only happens with DMD1.042+

Yay!



More information about the Digitalmars-d mailing list