Added a new check so that casting between tag types doesn't give the warning.  Casting to/from chars and voids won't throw the warning either.  Anything else needed?<br><br><div class="gmail_quote">On Mon, Apr 11, 2011 at 10:13 AM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.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 Apr 11, 2011, at 9:44 AM, Chandler Carruth wrote:<br>
> I share John and Doug's concern over false positive rates. However, I'd like to evaluate that by getting a conservative version of this in, trying it on some code, and evaluating the fallout. If this isn't useful we can drop it.<br>

<br>
</div>As long as it's off by default and enabled by some extremely specific<br>
flag like -Wpedantic-aliasing.  I am not willing to consider a diagnostic<br>
that's on by default unless it's policing the relaxed aliasing rules that<br>
Clang uses, where l-values that "obviously" alias are allowed to alias<br>
regardless of type.<br>
<div class="im"><br>
> However, I think we could do a couple of things more to avoid false-positives:<br>
><br>
> 1) Only warn on reference reinterpret casts when the result is in an lvalue-to-rvalue cast to avoid this false positive:<br>
><br>
> float f = 0.0f;<br>
> int *x = &reinterpret_cast<int&>(f);<br>
<br>
</div>That's probably reasonable.  I'd actually be okay with warning on this<br>
in general if you can come up with a small set of "universal-ish" types that<br>
you think it's reasonable to cast something through, like maybe void& and<br>
void*.<br>
<br>
Oh, and of course you can't warn about reinterpret_casts to/from<br>
references/pointers to char types.<br>
<div class="im"><br>
> 2) Don't warn for reinterpret casts of tag types.<br>
<br>
</div>Probably a good first iteration.<br>
<font color="#888888"><br>
John.<br>
</font></blockquote></div><br>