<div class="gmail_quote">On 11 March 2012 00:25, Sean Cavanaugh <span dir="ltr"><<a href="mailto:WorksOnMyMachine@gmail.com">WorksOnMyMachine@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 3/10/2012 4:37 AM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If I pass a structure TO a function by value, I know what happens, a<br>
copy is written to the stack which the function expects to find there.<br>
</blockquote>
<br></div>
This is only true if the compiler is forced to use the ABI, when inlining is impossible, or the type being passed is too complex. Structs of pods, most compilers do magical things to provided you don't actively work against the code gen (virtual methods, dllexports etc), too many separate .obj units in C++ etc.<br>

</blockquote></div><div><br></div><div>Talking about the typical case here, obviously not inlined, calling through the ABI, struct may be simple, just 2-3 values, can you show me a case where C++ is able to to anything particularly fancy?</div>
<div><br></div><div>I've never seen the compiler do wildly unexpected things unless whole program optimisation is enabled, which I don't imagine D will be able to support any time real soon?</div><div><br></div><div>
...and even then, relying on WPO for the language to generate good code in certain circumstances is a really really bad idea. This makes the task of implementing an efficient compiler for the language extremely difficult.</div>
<div>In most cases, making concise expression of the operation you want to perform possible in the language will generate better results anyway, without depending on an aggressive optimiser. It will also make the code more explicit and readable.</div>