[LLVMdev] Is va_arg correct on Mips backend?

Jonathan gamma_chen at yahoo.com.tw
Tue Feb 19 04:15:32 PST 2013


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;
}






More information about the llvm-dev mailing list