title: Why can't I dynamic_cast "sideways" during multiple inheritence?
body: <p>The following code throws std::bad_cast</p>
  
  <pre><code>struct Foo {
      void foo () {}
  };
  
  struct Bar {
      Bar () {
          dynamic_cast &lt;Foo &amp;&gt; (*this) .foo ();
      }
      virtual ~ Bar () {}
  };
  
  struct Baz : public Foo, public Bar {
  };
  
  int main ()
  {
      Baz b;
  }
  </code></pre>
  
  <p>I remember once reading how dynamic_cast has implementation performance trade-offs because "it traverses the full inheritence lattice" in order to evaluate correctly. What the compiler needs to do here is first cast up and then down again.</p>
  
  <p>Is it possible to make the above work or do I need to add
  <code>virtual Foo* Bar::as_foo()=0;</code>
  ?</p>