<p><br>
On Feb 13, 2013 6:55 PM, "Johannes Pfau" <<a href="mailto:nospam@example.com">nospam@example.com</a>> wrote:<br>
><br>
> Am Wed, 13 Feb 2013 17:17:06 +0000<br>
> schrieb Iain Buclaw <<a href="mailto:ibuclaw@ubuntu.com">ibuclaw@ubuntu.com</a>>:<br>
><br>
> > On 13 February 2013 15:20, Iain Buclaw <<a href="mailto:ibuclaw@ubuntu.com">ibuclaw@ubuntu.com</a>> wrote:<br>
> ><br>
> > >><br>
> > >> Complete test case:<br>
> > >> <a href="https://gist.github.com/jpf91/4944999">https://gist.github.com/jpf91/4944999</a><br>
> > >><br>
> > >> -----<br>
> > >><br>
> > >> ../../objdir-4.7/x86_64-unknown-linux-gnu/libphobos/dm-test.reduced/datetime2.d:22:<br>
> > >> internal compiler error: in create_tmp_var, at gimplify.c:479<br>
> > >> 0x804509 -----<br>
> > >><br>
> > >><br>
> > ><br>
> > > Ahh, that's because of this piece of codegen:<br>
> > ><br>
> > > SAVE_EXPR <*test.Date.this (&((void) (__ctmp971 =<br>
> > > _D4test4Date6__initZ);, __ctmp971), 0)><br>
> > ><br>
> > ><br>
> > > Gimple doesn't like the dereference in SAVE_EXPR. This should work.<br>
> > ><br>
> > > tree<br>
> > > IRState::makeTemp (tree t)<br>
> > > {<br>
> > > tree type = TREE_TYPE (t);<br>
> > > if (TREE_CODE (type) != ARRAY_TYPE && !TREE_ADDRESSABLE (type))<br>
> > > return save_expr (t);<br>
> > ><br>
> > > return stabilize_reference (t);<br>
> > > }<br>
> > ><br>
> > ><br>
> > > So the generated code is now:<br>
> > ><br>
> > > *SAVE_EXPR <test.Date.this (&((void) (__ctmp971 =<br>
> > > _D4test4Date6__initZ);, __ctmp971), 0)><br>
> > ><br>
> > ><br>
> > After some more playing about, David's suggestion would be the<br>
> > quickest. ;-)<br>
> ><br>
><br>
> Indeed. But what if the example is slightly adjusted to define a<br>
> destructor or postblit instead of the constructor? Does the backend<br>
> know about those or would it still try to pass Date in registers?<br>
></p>
<p>Backend doesn't know of those, and yes it would pass it in registers because it will always see structs as a value type rather than a reference (though passing round 'this' should always be done in memory).</p>
<p>Regards<br>
Iain. </p>