title: When do we break binary compatibility
body: <p>I was under the impression that whenever you do one of these:</p>
  
  <ul>
  <li>Add a new public virtual method <code>virtual void aMethod();</code></li>
  <li>Add a new public non-virtual method <code>void aMethod();</code></li>
  <li>Implement a public pure-virtual method from an interface <code>virtual void aMethod override;</code></li>
  </ul>
  
  <p>Was actually breaking binary compatibility, meaning that if a project had build on a previous version of the DLL, it would not be able to load it now that there is new methods available.</p>
  
  <p>From what I have tested using Visual Studio 2012, none of these break anything. Dependency Walker reports no error and my test application was calling the appropriate method.</p>
  
  <p>DLL:</p>
  
  <pre><code>class EXPORT_LIB MyClass {
  public:
    void saySomething();
  }
  </code></pre>
  
  <p>Executable:</p>
  
  <pre><code>int _tmain(int argc, _TCHAR* argv[])
  {
    MyClass wTest;
    wTest.saySomething();
    return 0;
  }
  </code></pre>
  
  <p>The only undefined behavior I found was if MyClass was implementing an pure-virtual interface and from my executable, I was calling one of the pure-virtual method and then I added a new pure-virtual method before the one used by my executable. In this case, Dependency Walker did not report any error but at runtime, it was actually calling the wrong method.</p>
  
  <pre><code>class IMyInterface {
  public:
    virtual void foo();
  }
  </code></pre>
  
  <p>In the executable</p>
  
  <pre><code>IMyInterface* wTest = new MyClass();
  wTest-&gt;foo();
  </code></pre>
  
  <p>Then I change the interface without rebuilding my executable</p>
  
  <pre><code>class IMyInterface {
  public:
    virtual void bar();
    virtual void foo();
  }
  </code></pre>
  
  <p>It is now quietly calling <code>bar()</code> instead of <code>foo()</code>.</p>
  
  <p>Is it safe to do all of my three assumptions?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Doing this</p>
  
  <pre><code>class EXPORT_LIB MyClass {
  public:
    virtual void saySomething();
  }
  </code></pre>
  
  <p>Exec</p>
  
  <pre><code>MyClass wTest;
  wTest.saySomething();
  </code></pre>
  
  <p>Then rebuild DLL with this:</p>
  
  <pre><code>class EXPORT_LIB MyClass {
  public:
    virtual void saySomething2();
    virtual void saySomething();
    virtual void saySomething3();
  }
  </code></pre>
  
  <p>Is calling the appropriate <code>saySomething()</code></p>