https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89923
Bug ID: 89923 Summary: printf format check and char8_t Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: drepper.fsp+rhbz at gmail dot com Target Milestone: --- With the introduction of char8_t there is a new error case in the printf format checks: #include <stdio.h> int main() { auto s = u8"hello world"; #pragma GCC diagnostic error "-Wformat" printf("%s\n", s); } Compiling this with C++2a results to the following output: $ g++ -c u.cc -std=gnu++2a u.cc: In function ‘int main()’: u.cc:6:12: error: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘const char8_t*’ [-Werror=format=] 6 | printf("%s\n", s); | ~^ ~ | | | | char* const char8_t* | %hhn I think char8_t* should be added to the allowed types for the %s parameter. It is arguably more likely to succeed then a char* argument since the latters encoding is determined by the compiler. At least with u8 strings the code can make sure the locale used at runtime uses UTF-8.