<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 26, 2013 at 12:37 AM, Alp Toker <span dir="ltr"><<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.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"><br>
On 22/11/2013 15:54, Ondřej Hošek wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've been trying to implement the relevant fix-it, but apart from not<br>
being able to find the end of the expression being cast (to insert the<br>
closing paren), the pathological case<br>
<br>
On Fri, Nov 22, 2013 at 2:13 AM, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(for example, static cast of a const cast)<br>
</blockquote>
might pose even more of a challenge, because I have to find and print<br>
the "halfway" type:<br>
<br>
int i = 42;<br>
const int *cpi = &i;<br>
float *fi = (float *)cpi;<br>
// -> reinterpret_cast<float *>(const_cast<int *>(cpi));<br>
<br>
This already spells trouble with regard to code formatting, and it<br>
gets worse if I have a multi-level pointer type where some of the<br>
levels are const and some aren't.<br>
</blockquote>
<br></div>
Hi Ondřej,<br>
<br>
I suspect the complexity of converting complex / multi-level C-style casts to C++-style casts just isn't worth the effort.<br></blockquote><div><br></div><div>Agreed. This almost borders on a stylistic choice better-suited for clang-tidy.</div>
<div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Even if you get it to work, the results wouldn't be pretty. It's better to encourage the developer to find an idiomatic solution by restructuring their code. Thanks for investigating this though.<br>
<br>
I'd say it's fine just to provide FixIt replacements for the common cases like straight const_cast<> that are easy to determine using existing CastOperation machinery.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
(Also, I have to move the warning from Parser to Sema because only<br>
then do I have the type information to generate a fix-it, so I don't<br>
know at all how well it will work with templates.)<br>
</blockquote>
<br></div>
It's also fine to work on this incrementally if you could prepare a patch similar to the original one but moving the check to the right place in Sema, along with a TODO about the FixIt. (It shouldn't be added to Parse because that's a clear dead-end.)<br>

<br>
I don't know what user expectations are for -Wold-style-cast, but it might be worth silently permitting the idiomatic C-style CK_ToVoid used to suppress unused variable warnings as a special case. Do you have an opinion on that?<br>

<br>
Alp.<div class="im HOEnZb"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
~~ Ondra<br>
______________________________<u></u>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-commits</a><br>
</blockquote>
<br></div><span class="HOEnZb"><font color="#888888">
-- <br>
<a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
the browser experts</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<u></u>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>