<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 26 June 2016 at 09:36, Iain Buclaw <span dir="ltr"><<a href="mailto:ibuclaw@gdcproject.org" target="_blank">ibuclaw@gdcproject.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 26 June 2016 at 03:30, Timon Gehr via Digitalmars-d<br>
<div><div class="h5"><<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br>
> On 17.06.2016 21:59, kinke wrote:<br>
>><br>
>><br>
>> Most interesting IMO though is the question when the slicee's pointer is<br>
>> to be loaded. This is only relevant if the base is an lvalue and may<br>
>> therefore be modified when evaluating the bound expressions. Should the<br>
>> returned slice be based on the slicee's buffer before or after<br>
>> evaluating the bounds expressions?<br>
>> This has been triggered by<br>
>> <a href="https://github.com/ldc-developers/ldc/issues/1433" rel="noreferrer" target="_blank">https://github.com/ldc-developers/ldc/issues/1433</a> as LDC loads the<br>
>> pointer before evaluating the bounds.<br>
><br>
><br>
> Evaluation order should be strictly left-to-right. DMD and GDC get it wrong<br>
> here.<br>
><br>
<br>
</div></div>It is evaluated left-to-right. getBase() -> getLowerBound() -> getUpperBound().<br>
</blockquote></div><br></div><div class="gmail_extra">Ah, I see what you mean.  I think you may be using an old GDC version.  Before I used to cache the result of getBase().<br><br></div><div class="gmail_extra">Old codegen:<br><br>_base = *(getBase());<br>_lwr = getLowerBound(_base.length);<br>_upr = getUpperBound(_base.length);<br>r = {.length=(_upr - _lwr), .ptr=_base.ptr + _lwr * 4};<br><br>---<br></div><div class="gmail_extra">Now when creating temporaries of references, the reference is stabilized instead.<br><br></div><div class="gmail_extra">New codegen:<br><br>*(_ptr = getBase());<br>_lwr = getLowerBound(_ptr.length);<br>_upr = getUpperBound(_ptr.length);<br>r = {.length=(_upr - _lwr), .ptr=_ptr.ptr + _lwr * 4};<br>---<br><br></div><div class="gmail_extra">I suggest you fix LDC if it doesn't already do this. :-)<br></div></div>