This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/30457] New: Please warn about va_start(ap, invalid)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]