title: Unsigned char automatically promoted to int in function call, why?
body: <p>Why is an <code>unsigned char</code> automatically promoted to an <code>int</code> when calling a function? In the example below there is an <code>f(int)</code> and a <code>f(char)</code> function. It seemed more logical that the compiler would coerce an <code>unsigned char</code> argument to a <code>char</code> and call <code>f(char)</code> since they have the same number of bits. It is calling <code>f(int)</code> instead, even when that means promoting the argument to a type with more bits. Any pointers to where the rule is defined? Standard or compiler/platform specific?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  void f( int key )
  {
      std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
  }
  
  void f( char key )
  {
      std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
  }
  
  int main( int argc, char* argv[] )
  {
      int a = 'a';
      char b = 'b';
      unsigned char c = 'c';
  
      f(a);
      f(b);
      f(c);
  
      return 0;
  }
  </code></pre>
  
  <p>Produces this output:</p>
  
  <pre><code>void f(int)
  void f(char)
  void f(int)
  </code></pre>