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/67854] New: Missing diagnostic for passing bool to va_arg


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

            Bug ID: 67854
           Summary: Missing diagnostic for passing bool to va_arg
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: miyuki at gcc dot gnu.org
  Target Milestone: ---

Consider the following code:

$ cat test.c
#include <stdarg.h>

void foo(va_list ap)
{
    va_arg(ap, char);
    va_arg(ap, unsigned char);
}

$ cc1 -std=c99 test.c 
In file included from test.c:1:0:
test.c: In function 'foo':
test.c:5:16: warning: 'char' is promoted to 'int' when passed through '...'
     va_arg(ap, char);
                ^
test.c:5:16: note: (so you should pass 'int' not 'char' to 'va_arg')
test.c:5:16: note: if this code is reached, the program will abort
test.c:6:16: warning: 'unsigned char' is promoted to 'int' when passed through
'...'
     va_arg(ap, unsigned char);
                ^
test.c:6:16: note: if this code is reached, the program will abort

However:

$ cat test2.c 
#include <stdbool.h>
#include <stdarg.h>

void foo(va_list ap)
{
    va_arg(ap, bool);
}

$ cc1 -std=c99 -Wall -Wextra test2.c

va_arg(ap, bool) is expanded into __builtin_trap, but no warning is issued.


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