<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 11 August 2017 at 16:55, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</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"><span class="gmail-">On 11 Aug 2017, at 4:37 pm, Shaheed Haque <<a href="mailto:srhaque@theiet.org">srhaque@theiet.org</a>> wrote:<br>
><br>
><br>
><br>
> On 11 August 2017 at 16:02, Phil Thompson <<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>> wrote:<br>
> On 11 Aug 2017, at 1:47 pm, Shaheed Haque <<a href="mailto:srhaque@theiet.org">srhaque@theiet.org</a>> wrote:<br>
> ><br>
> > Hi,<br>
> ><br>
> > Based on 4.19.4.dev1708081632, I see some issues with the emitted code involving casts. There are several cases, but here is one example that illustrates the issue:<br>
> ><br>
> > ===  4.19.4.dev1708081632 output ===<br>
> > static void assign_std_auto_ptr_0100GpgME_<wbr>EditInteractor(void *sipDst, SIP_SSIZE_T sipDstIdx, const void *sipSrc)<br>
> > {<br>
> >     reinterpret_cast< ::std::auto_ptr< ::GpgME::EditInteractor> *>(sipDst)[sipDstIdx] = *reinterpret_cast<const ::std::auto_ptr< ::GpgME::EditInteractor> *>(sipSrc);<br>
> > }<br>
> > ==============================<br>
> ><br>
> > The above won't compile with errors boiling down, IIUC, to the fact that the RHS has type "const something", and this is not compatible with the LHS which has type "something" without the const. Now, I'll confess that I'm a bit rusty on some of this, but I think the correct fix is to cast away the constness of sipSrc earlier, like this:<br>
> ><br>
> > === patched version ===<br>
> > static void assign_std_auto_ptr_0100GpgME_<wbr>EditInteractor(void *sipDst, SIP_SSIZE_T sipDstIdx, const void *sipSrc)<br>
> > {<br>
> >     reinterpret_cast< ::std::auto_ptr< ::GpgME::EditInteractor> *>(sipDst)[sipDstIdx] = *reinterpret_cast< ::std::auto_ptr< ::GpgME::EditInteractor> *>(const_cast<void *>(sipSrc));<br>
> > }<br>
> > ===================<br>
> ><br>
> > Now, the LHS and the RHS match, and the compiler is happy. There are 4 similar cases in gencode.c which I patched, as below. This patch also includes my diffs for the static_cast<int>s from <a href="https://www.riverbankcomputing.com/pipermail/pyqt/2017-August/039494.html" rel="noreferrer" target="_blank">https://www.<wbr>riverbankcomputing.com/<wbr>pipermail/pyqt/2017-August/<wbr>039494.html</a>.<br>
> ><br>
> > (There is also one slightly different usage of reinterpret_cast<const ...> but I am not sure if that is implicated or not).<br>
><br>
> I don't see why the RHS breaks the constness. Is std::auto_ptr doing something out of the ordinary?<br>
><br>
> As I hinted, I'm well outside my comfort zone here, so take anything say with a pinch of salt. That said...<br>
><br>
> It *might* well be auto_ptr-related, but I'm not sure, because the second paragraph on page <a href="http://en.cppreference.com/w/cpp/memory/auto_ptr" rel="noreferrer" target="_blank">http://en.cppreference.com/w/<wbr>cpp/memory/auto_ptr</a> seems to suggest that the RHS is being modified by the assignment (but that seems astonishing to me, so perhaps I am misreading it?). It is also true that all of the other templated types I am trying to support work fine in this regard.<br>
><br>
> At any rate, the voluminous errors that result all seem to point to the assignment itself being bad, and to my simple-minded thinking, the problem is more that with the original formulation, the RHS is a const-qualified type, while the LHS is not.<br>
<br>
</span>Yes but the expression is making a copy of the object on the RHS so the mis-match shouldn't make a difference.<span class="gmail-HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br>My reading is that the documentation saying that the RHS is changed by the assignment, and that the const is interfering with that!<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-HOEnZb"><font color="#888888">
Phil</font></span></blockquote></div><br></div></div>