title: c++ Empty template function returns non-empty function pointer
body: <p>I am confused by the function pointer of the template function.</p>
  <p>See</p>
  <pre><code>#include &lt;cstdio&gt;
  
  class A
  {
      public:
          A(){}
          ~A(){}
          void command()
          {
              printf(&quot;Cmd&quot;);   
          }
  };
  
  template&lt;class T&gt;
  void cmd_create()
  {
      T t;
      t.command();
  };
  
  int main()
  {
      typedef void(*Funcptr)();
      Funcptr f1 = &amp;cmd_create&lt;A&gt;;
      f1();
      return 0;
  }
  </code></pre>
  <p>The program output <code>Cmd</code>.</p>
  <p>The assembly (-O3) shows that</p>
  <pre><code>    .file   &quot;test.cpp&quot;
      .text
      .section    .rodata.str1.1,&quot;aMS&quot;,@progbits,1
  .LC0:
      .string &quot;Cmd&quot;
      .section    .text.startup,&quot;ax&quot;,@progbits
      .p2align 4,,15
      .globl  main
      .type   main, @function
  main:
  .LFB38:
      .cfi_startproc
      leaq    .LC0(%rip), %rsi
      subq    $8, %rsp
      .cfi_def_cfa_offset 16
      movl    $1, %edi
      xorl    %eax, %eax
      call    __printf_chk@PLT
      xorl    %eax, %eax
      addq    $8, %rsp
      .cfi_def_cfa_offset 8
      ret
      .cfi_endproc
  .LFE38:
      .size   main, .-main
      .ident  &quot;GCC: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0&quot;
      .section    .note.GNU-stack,&quot;&quot;,@progbits
  
  </code></pre>
  <p>Obviously, <code>&amp;cmd_create&lt;A&gt;</code> returns the A::command.</p>
  <p>The cmd_create is defined as an empty return (<strong>void</strong>), however, the code still gets the <code>A::command</code> in such a weird way.</p>
  <p>Thank you for your answer!</p>