title: Address of function is not actual code address
body: <p>Debugging some code in Visual Studio 2008 (C++), I noticed that the address in my function pointer variable is not the actual address of the function itself. This is an extern "C" function.</p>
  
  <pre><code>int main() {
     void (*printaddr)(const char *) = &amp;print; // debug shows printaddr == 0x013C1429
  
  }
  
  Address: 0x013C4F10
  void print() {
    ...
  }
  </code></pre>
  
  <p>The disassembly of taking the function address is:</p>
  
  <pre><code>   void (*printaddr)(const char *) = &amp;print;
  013C7465 C7 45 BC 29 14 3C 01 mov         dword ptr [printaddr],offset print (13C1429h) 
  </code></pre>
  
  <p>EDIT: I viewed the code at address 013C4F10 and the compiler is apparently inserting a "jmp" instruction at that address.</p>
  
  <pre><code>013C4F10 E9 C7 3F 00 00   jmp         print (013C1429h) 
  </code></pre>
  
  <p>There is actually a whole jump table of every method in the .exe.</p>
  
  <p>Can someone expound on why it does this? Is it a debugging "feature" ?</p>