title: Odd behavior without virtual inheritance
body: <p>I am working on a piece of code that presents a very odd behavior. I managed to replicate it in a simple hello world style program, following is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Test
  {
  public:
      virtual ~Test() = default;
  
  protected:
      virtual void SetUp() { }
  };
  
  class ICallbackReceiver
  {
  public:
      virtual ~ICallbackReceiver() = default;
      virtual void onReady() = 0;
  };
  
  // C-style callback
  void readyReceiver(void* userdata)
  {
      cout &lt;&lt; "3) readyReceiver\n";
      static_cast&lt;ICallbackReceiver*&gt;(userdata)-&gt;onReady();
  }
  
  using callback_t = void(*)(void*);
  callback_t myCallback;
  void* myUserData;
  
  void registerCallback(callback_t callback, void* userData)
  {
      cout &lt;&lt; "2) registerCallback\n";
      myCallback = callback;
      myUserData = userData;
  }
  
  class ConfigurableTest : public /*virtual*/ Test, public ICallbackReceiver
  {
  public:
  
      void SetUp() override
      {
          cout &lt;&lt; "1) ConfigurableTest::SetUp\n";
          registerCallback(&amp;readyReceiver, static_cast&lt;void*&gt;(this));
      }
  
      void onReady() override
      {
          cout &lt;&lt; "4) ConfigurableTest::onReady\n";
      }
  };
  
  int main()
  {
      ConfigurableTest test;
      test.SetUp();
  
      myCallback(myUserData);
  
      return 0;
  }
  </code></pre>
  
  <p>Whenever <code>myCallback</code> is called something has to be tested. And this is the output that should be displayed:</p>
  
  <pre><code>1) ConfigurableTest::SetUp
  2) registerCallback
  3) readyReceiver
  4) ConfigurableTest::onReady
  </code></pre>
  
  <p>But, unless I specify a <code>virtual</code> inheritance for the <code>Test</code> class, this is the output that I see:</p>
  
  <pre><code>1) ConfigurableTest::SetUp
  2) registerCallback
  3) readyReceiver
  1) ConfigurableTest::SetUp
  2) registerCallback
  </code></pre>
  
  <p>As you can see <code>ConfigurableTest::onReady</code> is never called, but <code>ConfigurableTest::SetUp</code> is actually called twice!</p>
  
  <p>What is the origin of this behavior? How can I re-factor the code to reproduce the correct behavior without using <code>virtual</code> inheritance?</p>