title: Under what conditions is the pure virtual method stub generated?
body: <p>I've read in many places (for example <a href="https://stackoverflow.com/questions/10707286/how-to-resolve-pure-virtual-method-called">here</a>) about people getting a "pure virtual method called" error and program crash at <strong>runtime</strong>. <a href="https://stackoverflow.com/a/2156691/1537925">This answer</a> says that</p>
  
  <blockquote>
    <p>Most compilers assign such vtable entries to a stub which emits an error before aborting the program.</p>
  </blockquote>
  
  <p>and <a href="https://stackoverflow.com/questions/14549489/how-to-fix-pure-virtual-function-called-runtime-error/14550864#14550864">this one</a> even says that Itanium ABI specifies what that stub is.</p>
  
  <p>The problem is: all my attempts to see this behaviour in action are caught by the compiler (GCC 6.4.1) at <strong>compile time</strong> as undefined references. For example, when calling a pure virtual function from a constructor of the abstract class, I get a warning</p>
  
  <p><code>pure virtual ‘virtual int X::f()’ called from constructor</code></p>
  
  <p>but at the same time simply no code at all is generated for <code>X::f()</code> so this is followed by</p>
  
  <p><code>undefined reference to 'X::f()'</code></p>
  
  <p>from the linker and the compilation fails. This seems a pretty foolproof way of preventing the error at runtime. In which situation would my compiler actually need to generate the aforementioned stub? Or has it gotten smart enough to detect all the possible pathological situations early enough?</p>