<div dir="ltr">On 29 October 2013 17:23, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im">On Tue, Oct 29, 2013 at 2:32 AM, Pohjolainen, Topi<br>
<<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>> wrote:<br>
> On Mon, Oct 28, 2013 at 11:31:32AM -0700, Matt Turner wrote:<br>
>> ---<br>
>>  src/mesa/drivers/dri/i965/brw_fs.cpp | 30 ++++++++++++++++++++++++++++++<br>
>>  src/mesa/drivers/dri/i965/brw_fs.h   |  1 +<br>
>>  2 files changed, 31 insertions(+)<br>
>><br>
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
>> index b2eac6c..28d369a 100644<br>
>> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
>> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
>> @@ -71,6 +71,36 @@ fs_inst::fs_inst()<br>
>>     init();<br>
>>  }<br>
>><br>
>> +fs_inst::fs_inst(const fs_inst *that)<br>
><br>
> Is there a particular reason why you chose to introduce this as a conversion<br>
> constructor instead of as a proper copy? I'm just afraid that it allows the<br>
> compiler to accept, for example, the following (which is probably not what the<br>
> author wanted):<br>
<br>
</div>No, in fact I really dislike this code. Is it safe to just memcpy the<br>
object in a copy constructor? Having to maintain the list of fields is<br>
awful.<br>
<br>
I'm happy to receive suggestions.<br>
<div class=""><div class="h5">_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div><div class="gmail_extra">The compiler automatically generates a default copy constructor that effectively does a memcpy*, but it has the signature:<br><br>    fs_inst::fs_inst(const fs_inst &)<br>
<br>instead of<br><br>    fs_inst::fs_inst(const fs_inst *)<br><br></div><div class="gmail_extra">So you can just drop this patch, and in patch 9/15 change<br><br>    cmp_inst = new(mem_ctx) fs_inst(m);<br><br></div><div class="gmail_extra">
to:<br><br></div><div class="gmail_extra">    cmp_inst = new(mem_ctx) fs_inst(*m);<br><br></div><div class="gmail_extra">(*actually the default copy constructor is smarter than a memcpy.  It memcpy's all the fields of the class that are safe to memcpy (those that don't have custom copy constructors), and calls the custom copy constructors on the rest.)<br>
</div></div>