This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/30457] New: Please warn about va_start(ap, invalid)
- From: "h dot b dot furuseth at usit dot uio dot no" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jan 2007 18:47:53 -0000
- Subject: [Bug c/30457] New: Please warn about va_start(ap, invalid)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Here is some undefined behavior which it would be nice if gcc
warned about, since stdarg is such a hairy part of the standard:
#include <stdarg.h>
void foo(register short paramN, ...)
{
va_list ap;
va_start(ap, paramN); // Undefined by C99 7.15.1.4p4 (va_start):
// "If the parameter parmN is declared with the register storage
// class, with a function or array type, or with a type that is
// not compatible with the type that results after application of
// the default argument promotions, the behavior is undefined."
// gcc does warn about the following, undefined by C99 7.15.1.1p2:
(void) va_arg(ap, char);
// "warning: 'char' is promoted to 'int' when passed through '...'
// warning: (so you should pass 'int' not 'char' to 'va_arg')
// note: if this code is reached, the program will abort"
va_end(ap);
}
--
Summary: Please warn about va_start(ap, invalid)
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: h dot b dot furuseth at usit dot uio dot no
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30457