title: Virtual inheritance bug in MSVC
body: <p>It seems that my problem is a bug in MSVC. I'm using the Visual Studio 2008 with Service Pack 1, and my code works with GCC (as tested on <a href="http://codepad.org/E3nwI8IF" rel="nofollow noreferrer">codepad.org</a>).</p>
  
  <p>Any official info on this bug? Any ideas how to work around it? Is the bug fixed in VS2010? All insights would be greatly appreciated.</p>
  
  <p>The code:</p>
  
  <pre><code>struct Base {
      Base(int i = 0) : i(i) {}
      virtual ~Base() {}
      virtual Base *clone() const = 0;
  
  protected:
      int i;
  };
  
  struct A : virtual public Base {
      A() {}
      virtual A *clone() const = 0;
  };
  
  struct B : public A {
      B() {}
      B *clone() const { return new B(*this); }
  
      /// MSVC debugger shows that 'b' is for some reason missing the Base
      /// portion of it's object ("Error: expression cannot be evaluated")
      /// and trying to access 'b.i' causes an unhandled exception.
      ///
      /// Note: This only seems to occur with MSVC
      B(const B &amp;b) : Base(b.i), A() {}
  };
  
  void foo(const A &amp;elem) {
      A *a = elem.clone();
      if (a) delete a;
  }
  
  int main() {
      A *a = new B;
      foo(*a);
      delete a;
  }
  </code></pre>