title: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call
body: <p>I created a simple program that demonstrates the runtime error I'm getting with my Qt application that uses multiple inheritance. The inheritance tree looks like:</p>
  
  <pre><code>QGraphicsItem (abstract)
        \
       QGraphicsLineItem      MyInterface (abstract)
                   \          /
                    \        /
                    MySubclass
  </code></pre>
  
  <p>And here is the code:</p>
  
  <pre><code>/* main.cpp */
  #include &lt;QApplication&gt;
  #include &lt;QGraphicsScene&gt;
  #include &lt;QGraphicsLineItem&gt;
  
  //simple interface with one pure virtual method
  class MyInterface
  {
  public:
    virtual void myVirtualMethod() = 0;
  };
  
  //Multiple inheritance subclass, simply overrides the interface method
  class MySubclass: public QGraphicsLineItem, public MyInterface
  {
  public:
    virtual void myVirtualMethod() { }
  };
  
  int main(int argc, char** argv)
  {
    QApplication app(argc, argv); //init QApplication
    QGraphicsScene *scene = new QGraphicsScene(); //create scene
  
    scene-&gt;addItem(new MySubclass()); // add my subclass to the scene
  
    Q_FOREACH(QGraphicsItem *item, scene-&gt;items()) // should only have one item
    {
      MyInterface *mInterface = (MyInterface*)item; // cast as MyInterface
      mInterface-&gt;myVirtualMethod(); // &lt;-- this causes the error
    }
    return 0;
  }
  </code></pre>
  
  <p>Debugging in visual studio results in a runtime error when my interface method is called:</p>
  
  <pre><code>    Run-Time Check Failure #0 - The value of ESP was not properly 
      saved across a function call.  This is usually a result of 
      calling a function declared with one calling convention with 
      a function pointer declared with a different calling convention.
  </code></pre>
  
  <p>Any idea what the problem is?</p>