title: What is a C++ "Key Function" as described by gold?
body: <p>Please do not answer the question "how do I solve this error message?"</p>
  
  <p>In the error message provided by gold:</p>
  
  <pre><code>/usr/bin/ld.gold: the vtable symbol may be undefined
  because the class is missing its key function
  </code></pre>
  
  <p>What is a <code>key function</code>? I find reference to it in the <a href="https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html" rel="noreferrer">GCC manual page for Function Attributes</a> under the section <code>dllimport</code>. The relevant text reads:</p>
  
  <blockquote>
    <p>On the SH Symbian OS target the dllimport attribute also has another affect (sic)—it can cause the vtable and run-time type information for a class to be exported. This happens when the class has a dllimport'ed constructor or a non-inline, non-pure virtual function and, for either of those two conditions, the class also has an inline constructor or destructor and has a key function that is defined in the current translation unit. </p>
  </blockquote>
  
  <p>From this I take away that there is some function distinct from constructors or destructors, required under some conditions, when using the <code>dllimport</code> attribute, on Symbian OS. Interesting, but I'm compiling for Linux on Linux, and <code>grep -r dllimport</code> reveals nothing. So this paragraph does not apply.</p>
  
  <p>(FWIW the problem derives (in this instance) from an undefined <em>destructor</em> but both the documentation and the output of the linker go to great pains to distinguish a "key function" from a destructor. For other kinds of missing symbols, the linker spells the name of the missing symbol.)</p>
  
  <p>So, what is a <code>key function</code> <em>really</em>?</p>