[LLVMbugs] [Bug 10810] New: Function prototype with K&R definition and resulting call.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Aug 29 21:10:31 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10810
Summary: Function prototype with K&R definition and resulting
call.
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jpbonn-keyword-llvmbug.a51747 at corniceresearch.com
CC: llvmbugs at cs.uiuc.edu
I believe this to be a bug. 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. I believe either an warning/error
should be generated or the generated code should be non-varargs.
This code was derived from a test in the gcc test suite. This happens when
using clang with the -O0 option.
If the prototype and definition of the function is:
static void attr_eq(char *);
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);
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list