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

            Bug ID: 89379
           Summary: -Wformat is supposed not to give warning
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lvenkatakumarchakka at gmail dot com
  Target Milestone: ---

I have written code as follows:

#include<inttypes.h>
#include<stdio.h>

int main()
{
        uint16_t value;
        scanf( "%"PRIu16, &value );
}

seeing warning

$ gcc foo.c -Wformat
foo.c: In function ‘main’:
foo.c:7:9: warning: format ‘%u’ expects argument of type ‘unsigned int *’, but
argument 2 has type ‘uint16_t *’ {aka ‘short unsigned int *’} [-Wformat=]
  scanf( "%"PRIu16, &value );
         ^~~        ~~~~~~
In file included from foo.c:1:
/usr/include/inttypes.h:103:19: note: format string is defined here
 # define PRIu16  "u"

Reply via email to