<div dir="ltr"><div class="gmail_extra">Now I'm working to fix issue 6620</div><div class="gmail_extra"><br></div><div class="gmail_extra"><a href="https://issues.dlang.org/show_bug.cgi?id=6620">https://issues.dlang.org/show_bug.cgi?id=6620</a></div><div class="gmail_extra"><a href="https://github.com/D-Programming-Language/dmd/pull/4035">https://github.com/D-Programming-Language/dmd/pull/4035</a></div><div class="gmail_extra"><br></div><div class="gmail_extra">Kenji Hara</div><div class="gmail_extra"><br><div class="gmail_quote">2014-04-01 20:49 GMT+09:00 Johannes Pfau <span dir="ltr"><<a href="mailto:nospam@example.com" target="_blank">nospam@example.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I started fixing GDC bug #8 (*) which is basically that array op<br>
evaluation order currently depends on the target architecture. Consider<br>
this example:<br>
a()[] = b()[] + c()[];<br>
The order in which c,a,b are called is currently architecture specific.<br>
As stated in that bug report by Andrei we want this to evaluate LTR, so<br>
a() first, then b(), then c().<br>
<br>
These operations are actually rewritten to calls to extern(C)<br>
functions. Arguments to C function should be evaluated LTR as well, but<br>
dmd currently evaluates them RTL (GDC: architecture dependent). In order<br>
to fix the array op bug in gdc we have to define the evaluation order<br>
for extern(C) function parameters.<br>
<br>
So I've changed extern(C) functions to evaluate LTR in GDC and then had<br>
to change the array op code, cause that assumed extern(C) function<br>
evaluate RTL. Now I'd like to push these array op changes into dmd as we<br>
want to keep as few gdc specific changes as possible and dmd (and ldc)<br>
will need these changes anyway as soon as they implement extern(C)<br>
functions as LTR. This is required by dmd issue #6620 (**) and the<br>
language spec (***).<br>
<br>
However, if we apply only these changes the array op order reverses for<br>
DMD as it evaluates extern(C) function arguments RTL.<br>
<br>
So I need someone with dmd backend knowledge to fix the evaluation<br>
order of extern(C) function parameters to be LTR.<br>
Evaluation order of assignments should also be fixed to be LTR in the<br>
dmd backend. Although not strictly required for the array op changes<br>
it'd be inconsistent to have array op assignments execute LTR but<br>
normal assignments RTL:<br>
a()[] = b()[] + c()[]; //Array op assignment<br>
a() = b() + c();       //Normal assignment<br>
 |      |    |<br>
 1      2    3<br>
<br>
The frontend changes for dmd are here:<br>
<a href="https://github.com/jpf91/dmd/tree/fixOrder" target="_blank">https://github.com/jpf91/dmd/tree/fixOrder</a><br>
Frontend:<br>
<a href="https://github.com/jpf91/dmd/commit/5d61b812977dbdc1f99100e2fbaf1f45e9d25b03" target="_blank">https://github.com/jpf91/dmd/commit/5d61b812977dbdc1f99100e2fbaf1f45e9d25b03</a><br>
Test cases:<br>
<a href="https://github.com/jpf91/dmd/commit/82bffe0862b272f02c27cc428b22a7dd113b4a07" target="_blank">https://github.com/jpf91/dmd/commit/82bffe0862b272f02c27cc428b22a7dd113b4a07</a><br>
<br>
Druntime changes (need to be applied at the same time as dmd changes)<br>
<a href="https://github.com/jpf91/druntime/tree/fixOrder" target="_blank">https://github.com/jpf91/druntime/tree/fixOrder</a><br>
<a href="https://github.com/jpf91/druntime/commit/f3f6f49c595d4fb25fb298e435ad1874abac516d" target="_blank">https://github.com/jpf91/druntime/commit/f3f6f49c595d4fb25fb298e435ad1874abac516d</a><br>
<br>
<br>
(*)   <a href="http://bugzilla.gdcproject.org/show_bug.cgi?id=8" target="_blank">http://bugzilla.gdcproject.org/show_bug.cgi?id=8</a><br>
(**)  <a href="https://d.puremagic.com/issues/show_bug.cgi?id=6620" target="_blank">https://d.puremagic.com/issues/show_bug.cgi?id=6620</a><br>
(***) <a href="https://github.com/D-Programming-Language/dlang.org/pull/6" target="_blank">https://github.com/D-Programming-Language/dlang.org/pull/6</a><br>
</blockquote></div><br></div></div>