Strange error

monarch_dodra monarchdodra at gmail.com
Thu Jul 4 02:17:36 PDT 2013


On Thursday, 4 July 2013 at 08:34:24 UTC, Temtaime wrote:
> Hello guys !
> I'm found strange error when compiling following code:
>
> http://dpaste.1azy.net/b40ce9a4
>
> The error is:
> src\phobos\std\stdio.d(1872): Error: variable _param_1 used 
> before set
>
> Problem exists only when using following options: -inline -O
> I'm using DMD 2.063.2 on Windows.
>
> Can anybody help with it ? Also i can't minimize the test-case.

Looks like a bug related with size 0 matrices: It makes you 
declare an empty static array, which then does some conflicts, 
since the code to "initialize" it is optimized out. Reduced test 
case:

--------
struct S
{
     int[0] a;

     void do_it()
     {
         foo(a);
     }
}

void foo(Args...)(Args args)
{
     foreach(arg; args)
         if (arg.ptr == null)
             return;

     bar(args);
}

void bar(Args...)(Args args)
{
     baz(args);
}

void baz(Args...)(Args args)
{
     foreach(arg; args)
         if (arg.ptr == null)
             return;
}

void main()
{}
--------

I've filed it:
http://d.puremagic.com/issues/show_bug.cgi?id=10540

To workaround it, I'd suggest writing your code in such a way 
that you stop the recursion a "1", and not "0".


More information about the Digitalmars-d-learn mailing list