title: Function pointers assignment
body: <p>Following the question <a href="https://stackoverflow.com/questions/15653604/function-pointer-in-visual-studio-2012/15653714#15653714">Function pointer in Visual Studio 2012</a> I've started to wonder about the legality of certain assignments to function pointers in C.</p>
  
  <p>The code below compiles with a warning, like I would expect because the assigned function requires <strong>more</strong> parameters than the function pointer declaration describes (<a href="http://liveworkspace.org/code/3mnLvT$2" rel="nofollow noreferrer">GCC 4.8</a>):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int test(int x, int y)
  {
      printf("%d", x);
      printf("%d", y);
      return 0;
  }
  
  int main()
  {
      int (*test_ptr)(int);
      test_ptr = test;
      test_ptr(1);
      return 0;
  }
  </code></pre>
  
  <p>Same warning appears if changing the code so that assigned function requires <strong>less</strong> parameters (<a href="http://liveworkspace.org/code/3kVPvH$0" rel="nofollow noreferrer">GCC 4.8</a>). Again, this is expected.</p>
  
  <p>However, the following code compiles without a single warning, although the assigned function needs 2 parameters instead of 0 (<a href="http://liveworkspace.org/code/2vzpu1$26" rel="nofollow noreferrer">GCC 4.8</a>):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int test(int x, int y)
  {
      printf("%d", x);
      printf("%d", y);
      return 0;
  }
  
  int main()
  {
      int (*test_ptr)();
      test_ptr = test;
      test_ptr();
      return 0;
  }
  </code></pre>
  
  <p>No castings are involved anywhere.</p>
  
  <p>Can anyone explain this compiler behavior?</p>