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

Mark Wielaard <mark at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at gcc dot gnu.org

--- Comment #5 from Mark Wielaard <mark at gcc dot gnu.org> ---
Note that this also triggers for code that looks just fine to the user:

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

int
main (int argc, char **argv)
{
  uint8_t u = 16;
  printf ("u = %02" PRIx8 "\n", u);
  return 0;
}

m.c: In function ‘main’:
m.c:8:11: warning: format ‘%x’ expects argument of type ‘unsigned int’, but
argument 2 has type ‘int’ [-Wformat=]
   printf ("u = %02" PRIx8 "\n", u);
           ^

Which is somewhat surprising since the user explicitly matched the type and
format specifier.

This is caused by the definition of the PRIx format specifiers all mapping back
to "x" in inttypes.h

/* lowercase hexadecimal notation.  */
# define PRIx8          "x"
# define PRIx16         "x"
# define PRIx32         "x"

Reply via email to