<div dir="ltr">Thanks for feedback! Here is an updated version. It warns by default in case of virtual base or in case of nonzero offset. Other up/downcasts lead to a warning with -Wreinterpret-updown-extra, ignored by default.</div>

<div class="gmail_extra"><br><br><div class="gmail_quote">On 23 January 2013 04:31, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@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 style="word-wrap:break-word"><div><div class="h5"><br><div><div>On Jan 22, 2013, at 16:08 , John McCall <<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>> wrote:</div><br><blockquote type="cite">

<div style="word-wrap:break-word"><div><div>On Jan 22, 2013, at 2:58 PM, Alexander Zinenko <<a href="mailto:ftynse@gmail.com" target="_blank">ftynse@gmail.com</a>> wrote:</div><blockquote type="cite"><div dir="ltr">

<div>The attached patch addresses <a href="http://llvm.org/bugs/show_bug.cgi?id=13824" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=13824</a>. It emits a warning if reinterpret_cast is actually used to perform an upcast or a downcast which might lead to segfault in some cases.</div>

</div></blockquote><div><br></div>In most cases, this is actually safe, and I don't feel comfortable saying it's unreasonable for code to rely on that.  This warning should only fire when the base subobject is in a virtual base or at a nonzero static offset.</div>

<div><br></div><div>You can use a CXXBasePaths object with Sema::IsDerivedFrom in order to determine the subobject access path.</div></div></blockquote><br></div></div></div><div>I think I would still have a warning, since reinterpret_cast is harder to check statically and therefore is less future-proof. But I could see that warning being controlled by a separate flag.</div>

<span class="HOEnZb"><font color="#888888"><div><br></div><div>Jordan</div><div><br></div></font></span></div></blockquote></div><br></div>