<div dir="ltr">Reported.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 10 January 2014 15:34, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 1/9/14 9:08 PM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So I'm interacting with C (although it works the same in D), I call a<br>
function that returns a pointer, and gives the size through an out arg:<br>
ubyte* test(size_t* ptr)<br>
{<br>
*ptr = 100;<br>
return cast(ubyte*)1234;<br>
}<br>
<br>
<br>
And call it, but immediately use the size argument to slice a range:<br>
size_t size;<br>
ubyte[] t = test(&size)[0..size];<br>
<br>
t is null.<br>
<br>
If I do this, it works:<br>
size_t size;<br>
ubyte* pt = test(&size);<br>
ubyte[] t = pt[0..size];<br>
<br>
Why should I need that extra line?<br>
</blockquote>
<br></div></div>
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.<span class="HOEnZb"><font color="#888888"><br>
<br>
Andrei<br>
<br>
</font></span></blockquote></div><br></div>