<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jun 18, 2013, at 8:36 AM, Pavel Labath <<a href="mailto:labath@google.com">labath@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr">Greetings,<div><br></div><div>recently I've found a bug in the static analyzer <<a href="http://llvm.org/bugs/show_bug.cgi?id=16308">http://llvm.org/bugs/show_bug.cgi?id=16308</a>>, where it crashed processing code like this:</div><div>-----</div><div><pre class="" id="comment_text_0" style="white-space: pre-wrap; width: 50em;">struct A;
struct B{ virtual ~B(); };
class B2 : public B { };
void f(A *a) {
  B *b=(B *)a;
  B2 *b2=dynamic_cast<B2 *>(b);
}</pre><pre class="" id="comment_text_0" style="white-space: pre-wrap; width: 50em;"><span style="color: rgb(34, 34, 34); font-family: arial; white-space: normal;">-----</span></pre><pre class="" id="comment_text_0" style="width: 50em;"><font face="arial"><span style="white-space: normal;">because A has incomplete type. Besides fixing the crash, </span></font><font face="arial">I was thinking I could add a diagnostic which would detect patterns like this. The problem here is the reinterpret_cast to a non-standard-layout type, which invokes undefined behavior. </font><span style="font-family: arial;">Since this is fairly easy to detect, I started wondering if there is a reason it is not implemented yet. Is it because the pattern is too common in the code and would be an annoyance? Or am I missing something obvious here ?</span></pre></div></div></div></blockquote>As far as I know we have not tried adding this diagnostic. I am not sure what the false positive rate would be. <br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"><div><pre class="" id="comment_text_0" style="width: 50em;"><span style="white-space: normal; font-family: arial;"><br></span></pre><pre class="" id="comment_text_0" style="width: 50em;"><span style="white-space: normal; font-family: arial;">cheers,</span></pre><pre class="" id="comment_text_0" style="width: 50em;"><span style="white-space: normal; font-family: arial;">pl</span></pre></div></div>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></div></blockquote></div><br></body></html>