<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;color:rgb(0,0,0)">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;color:rgb(0,0,0)"><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, 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. </span></font><span style="white-space:normal;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>
<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>