I'm noticing some behavior I don't understand. There is a function prototype in scope but the function definition is K&R style. My understanding is the actual call to the function should be non-varargs since the prototype is present. What I'm seeing is the call is being made as a varargs call. What is the correct behavior in this case?
This code was derived from a test in the gcc test suite. This happens when using clang with the -O0 option.
If the definition of the function is:
static void
attr_eq (name)
char * name;
{...}
The call generated is:
call void (...)* bitcast (void (i8*)* @attr_eq to void (...)*)(i8* getelementptr inbounds ([5 x i8]* @arg0, i32 0, i32 0))
Here's the complete code:
extern void abort (void);
static char arg0[] = "arg0";
static void attr_eq (char *);
void attr_rtx (char *);
char *attr_string (char *);
static void
attr_eq (name)
char * name;
/*
attr_eq (char * name)
*/
{
attr_rtx (attr_string (name));
}
int main()
{
attr_eq (arg0);
exit (0);
}