title: Optimizing out helper functions
body: <p>This is more or less a request for clarification on
  <a href="https://stackoverflow.com/questions/559581/casting-a-function-pointer-to-another-type/561040#561040">Casting a function pointer to another type</a> with example code</p>
  
  <pre><code>struct my_struct;
  void my_callback_function(struct my_struct* arg);
  void do_stuff(void (*cb)(void*));
  
  static void my_callback_helper(void* pv)
  {
      my_callback_function(pv);
  }
  int main()
  {
      do_stuff(&amp;my_callback_helper);
  }
  </code></pre>
  
  <p>The answer says a "good" compiler should be able to optimize out 
  the <code>my_callback_helper()</code> function but I found no compiler at <a href="https://godbolt.org/g/Km5nqy" rel="noreferrer">https://gcc.godbolt.org</a>
   that does it and the helper function gets always generated even if it's <a href="https://godbolt.org/g/Km5nqy" rel="noreferrer">just a jump to <code>my_callback_function()</code></a> (-O3):</p>
  
  <pre><code>my_callback_helper:
          jmp     my_callback_function
  main:
          subq    $8, %rsp
          movl    $my_callback_helper, %edi
          call    do_stuff
          xorl    %eax, %eax
          addq    $8, %rsp
          ret
  </code></pre>
  
  <p>So my question is: Is there anything in the standard that prevents compilers from eliminating the helper?</p>