title: virtual functions and static_cast
body: <p>Can i safely call virtual functions after using static_cast on polymorphic class in situations like in the following code or is it UB?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Base
  {
  public:
     virtual void foo() { std::cout &lt;&lt; "Base::foo() \n"; }
  };
  
  class Derived : public Base
  {
  public:
     virtual void foo() { std::cout &lt;&lt; "Derived::foo() \n"; }
  };
  
  int main()
  {
     Base* derived = new Derived;
     Derived* _1 = static_cast&lt;Derived*&gt;(derived);
     _1-&gt;foo();
  }
  </code></pre>