Reported.

On 10 January 2014 15:34, Andrei Alexandrescu <[email protected]
> wrote:

> On 1/9/14 9:08 PM, Manu wrote:
>
>> So I'm interacting with C (although it works the same in D), I call a
>> function that returns a pointer, and gives the size through an out arg:
>>    ubyte* test(size_t* ptr)
>>    {
>> *ptr = 100;
>> return cast(ubyte*)1234;
>>    }
>>
>>
>> And call it, but immediately use the size argument to slice a range:
>>    size_t size;
>>    ubyte[] t = test(&size)[0..size];
>>
>> t is null.
>>
>> If I do this, it works:
>>    size_t size;
>>    ubyte* pt = test(&size);
>>    ubyte[] t = pt[0..size];
>>
>> Why should I need that extra line?
>>
>
> It's a bug in the compiler. Evaluation should proceed as if it were
> strictly left to right. So test(&size) must be called before size is loaded
> to construct the slice. Please report.
>
> Andrei
>
>

Reply via email to