[Bug c++/89923] printf format check and char8_t

tom at honermann dot net gcc-bugzilla@gcc.gnu.org
Fri Apr 5 19:16:00 GMT 2019


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

--- Comment #4 from Tom Honermann <tom at honermann dot net> ---
(In reply to Florian Weimer from comment #3)
> But the precedent with wchar_t is that the type of the format string
> determines the type of the %s arguments.  I'm not sure if that's a good
> precedent, but it's what we have today.

That matches Microsoft's documented behavior
(https://docs.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=vs-2019),
but it runs contrary to the C standard (C11 7.29.2.1) and glibc behavior.

To be clear, the position I'm suggesting is that we add support for something
like these:

  printf("%U8s", u8"text");
  printf("%U8c", u8'x');
  wprintf(L"%U8s", u8"text");
  wprintf(L"%U8c", u8'x');

  printf("%U16s", u"text");
  printf("%U16c", u'x');
  wprintf(L"%U16s", u"text");
  wprintf(L"%U16c", u'x');

  printf("%U32s", U"text");
  printf("%U32c", U'x');
  wprintf(L"%U32s", U"text");
  wprintf(L"%U32c", U'x');


More information about the Gcc-bugs mailing list