title: Losing RTTI info after returning from a function
body: <p>Given a class and subclass:</p>
  
  <pre><code>class Event {...}
  class Note : public Event {...}
  </code></pre>
  
  <p>A Note is Cloned and stored in a pointer within a function f(). The type-information is preserved in the pointer and can be recovered by dynamic_cast:</p>
  
  <pre><code>void f()
  {
     pEvent = pNote-&gt;Clone();    // create a clone of a Note
     ASSERT(dynamic_cast&lt;Note*&gt;(pEvent));   // check the pointer, here it works
  }
  </code></pre>
  
  <p>Now, after returning from f() the type-information is lost:</p>
  
  <pre><code>f();
  ASSERT(dynamic_cast&lt;Note*&gt;(pEvent));   // -&gt; "Access violation - no RTTI-data"
  </code></pre>
  
  <p>The VS-debugger shows a valid pointer-value (unchanged), but not the derived class,
  other than while beeing in the <code>f()</code>-scope.</p>
  
  <p>How can the RTTI-info for a pointer be lost when returning from a function?</p>