[LLVMdev] Is va_arg correct on Mips backend?

Jonathan
Tue, 19 Feb 2013 12:15:32 -0000

I check the Mips backend for the following C code fragment compile result. It
seems not correct. Is it my misunderstand or it's a bug.

//ch8_3.cpp
#include <stdarg.h>

int sum_i(int amount, ...)
{
  int i = 0;
  int val = 0;
  int sum = 0;

  va_list vl;
  va_start(vl, amount);
  for (i = 0; i < amount; i++)
  {
    val = va_arg(vl, int);
    sum += val;
  }
  va_end(vl);

  return sum;
}

int main()
{
  int a = sum_i(6, 1, 2, 3, 4, 5, 6);

  return a;
}