title: Weird behaving ellipsis function (va_list)
body: <p>The following <code>max</code> function is supposed to return 5 but it returns 4294967294 instead. I suspect the weird behavior arise from casting variables but couldn't figure it out. Can someone detect the fault?</p>
  
  <p>System: Windows 7 (64 bits), mingw64</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;limits.h&gt;
  #include &lt;stdarg.h&gt;
  #include &lt;inttypes.h&gt;
  
  int64_t max(int64_t n, ...) {
      va_list v;
      int64_t i, t, max = INT64_MIN;
  
      va_start(v, n);
  
      for (i = 0; i &lt; n; i++) {
          t = va_arg(v, int64_t);
  
          if (max &lt; t) {
              max = t;
          }
      }
  
      va_end(v);
      return (max);
  }
  
  int main(int argc, char **argv) {
      printf("max(3, 1, 5, -2)   : %3I64d\n", max(3, 1, 5, -2));
      return (0);
  }
  </code></pre>