https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65901

            Bug ID: 65901
           Summary: no warning or error for va_arg (ap, void)
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

We have va_arg (ap, void) somewhere in the testsuite
(gcc.c-torture/compile/pr48767.c).

AFAIU, using void in va_arg is undefined behaviour in c.

Currently, we just compile it without warning or error:
...
$ cat ~/va-arg-void.c
#include <stdarg.h>

int
f (int d, ...)
{
  int res;
  va_list ap;
  va_start (ap, d);
  va_arg (ap, void);
  res = va_arg (ap, int);  
  va_end (ap);
  return res;
}

int
main (void)
{
  return f (1, 2, 3);
}
$ gcc -O2 ~/va-arg-void.c
$ ./a.out ; echo $?
3
...

Btw, note that va_arg (ap, void) has an effect on ap.

Reply via email to