title: Default argument promotions in C function calls
body: <h2>Setup</h2>
  
  <p>I have a few questions about the default argument promotions when calling a function in C.  Here's section 6.5.2.2 "Function calls" Paragraphs 6, 7, and 8 from the <a href="http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf" rel="noreferrer">C99 standard (pdf)</a> (emphasis added and broken into lists for ease of reading):</p>
  
  <p><strong>Paragraph 6</strong></p>
  
  <blockquote>
    <ol>
    <li>If the expression that denotes the called function has a type that <strong>does not include a prototype</strong>, the integer promotions are performed on each argument, and arguments that have type <code>float</code> are promoted to <code>double</code>. These are called the <strong><em>default argument promotions</em></strong>.</li>
    <li>If the number of arguments does not equal the number of parameters, the behavior is undefined.</li>
    <li>If the function is defined with a type that <strong>includes a prototype</strong>, and either the prototype ends with an ellipsis (<code>, ...</code>) or the types of the arguments after promotion are not compatible with the types of the parameters, the behavior is undefined.</li>
    <li>If the function is defined with a type that <strong>does not include a prototype</strong>, and the types of the arguments after promotion are not compatible with those of the parameters after promotion, the behavior is undefined, except for the following cases:
    
    <ul>
    <li>one promoted type is a signed integer type, the other promoted type is the corresponding unsigned integer type, and the value is representable in both types;  </li>
    <li>both types are pointers to qualified or unqualified versions of a character type or <code>void</code>.</li>
    </ul></li>
    </ol>
  </blockquote>
  
  <p><strong>Paragraph 7</strong></p>
  
  <blockquote>
    <ol>
    <li>If the expression that denotes the called function has a type that <strong>does include a prototype</strong>, the arguments are implicitly converted, as if by assignment, to the types of the corresponding parameters, taking the type of each parameter to be the unqualified version of its declared type.</li>
    <li>The ellipsis notation in a function prototype declarator causes argument type conversion to stop after the last declared parameter. <strong>The default argument promotions are performed on trailing arguments.</strong></li>
    </ol>
  </blockquote>
  
  <p><strong>Paragraph 8</strong></p>
  
  <blockquote>
    <ol>
    <li>No other conversions are performed implicitly; in particular, the number and types of arguments are not compared with those of the parameters in a function definition that <strong>does not include a function prototype declarator</strong>.</li>
    </ol>
  </blockquote>
  
  <h2>What I know</h2>
  
  <ul>
  <li>The <em>default argument promotions</em> are <code>char</code> and <code>short</code> to <code>int</code>/<code>unsigned int</code> and <code>float</code> to <code>double</code></li>
  <li>The optional arguments to variadic functions (like <code>printf</code>) are subject to the default argument promotions</li>
  </ul>
  
  <p>For the record, my understanding of a <em>function prototype</em> is this:</p>
  
  <pre><code>void func(int a, char b, float c);  // Function prototype
  void func(int a, char b, float c) { /* ... */ }  // Function definition
  </code></pre>
  
  <h2>Question</h2>
  
  <p>I'm having a really hard time groking all of this.  Here are some questions I have:</p>
  
  <ul>
  <li>Do prototyped and non-prototyped functions' behavior really differ so much, such as with regard to default promotions and implicit conversions?</li>
  <li>When do default argument promotions occur?  Is it always?  Or is it just in special cases (like with variadic functions)?  Does it depend on whether a function is prototyped?</li>
  </ul>