[LLVMbugs] [Bug 10201] New: clang does not warn on va_arg(args, float)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jun 27 09:41:28 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10201
Summary: clang does not warn on va_arg(args, float)
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jonathan.sauer at gmx.de
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Please consider the following program:
/* From stdarg.h: */
typedef __builtin_va_list va_list;
#define va_arg(ap, type) __builtin_va_arg(ap, type)
static void foo(va_list args)
{
/* Should be <double> */
va_arg(args, float);
}
When this is compiled using Apple's GCC 4.2, GCC outputs this:
$ gcc -S clang.c
clang.c: In function ‘void foo(__va_list_tag*)’:
clang.c:9: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
clang.c:9: warning: (so you should pass ‘double’ not ‘float’ to ‘va_arg’)
clang.c:9: note: if this code is reached, the program will abort
When compiled with clang r133415, on the other hand, no warning is printed,
even though the code still does not work:
$ clang -S clang.c
Background for this are ISO C99 6.5.2.2p6 and p7:
If the expression that denotes the called function has a type that does not
include a prototype, [...] arguments that have type float are promoted to
double. These are called the default argument promotions.
[...] The ellipsis notation in a function prototype declarator causes argument
type conversion to stop after the last declared parameter. The default argument
promotions are performed on trailing arguments.
--
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