https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77520
Bug ID: 77520 Summary: wrong value for extended ASCII characters in -Wformat message Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The argument_parser::find_format_char_info function is c-family/c-format.c passes the value of an unexpected format character whose type is char as an argument to a %x directive. When char is a signed type and the value is in the extended ASCII range ('\x80' and greater) it is sign-extended and yields a very large value on output as in the test case below. The character should be cast to unsigned char to avoid the sign extension. The following test case shows the problem: $ cat t.c && /home/msebor/build/gcc-49905/gcc/xgcc -B/home/msebor/build/gcc-49905/gcc -S -Wformat t.c void f (void) { __builtin_printf ("%\x80"); } t.c: In function âfâ: t.c:3:23: warning: unknown conversion type character 0xffffff80 in format [-Wformat=] __builtin_printf ("%\x80"); ^~~~ Clang produces better output: t.c:3:23: warning: invalid conversion specifier '\x80'