public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -Wformat and u8""
@ 2022-05-09  9:15 Ulrich Drepper
  2022-05-09  9:26 ` Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Drepper @ 2022-05-09  9:15 UTC (permalink / raw)
  To: gcc

I have a C++20+ code base which forces the program to run using an UTF-8
locale and then uses u8"" strings internally.  This causes warnings with
-Wformat.

#include <stdio.h>

int main()
{
  printf((const char*) u8"test %d\n", 1);
  return 0;
}

Compile with
   g++ -std=gnu++20 -c -O -Wall t.cc

and you'll see:
t.cc: In function ‘int main()’:
t.cc:5:24: warning: format string is not an array of type ‘char’ [-Wformat=]
    5 |   printf((const char*) u8"test %d\n", 1);
      |                        ^~~~~~~~~~~~~

I would say it is not gcc's business to question my use of u8"" given that
I use a cast and the u8"" string can be parsed by the -Wformat handling.

Before filing a report I'd like to take the temperature and see whether
people agree with this.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-10 17:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09  9:15 -Wformat and u8"" Ulrich Drepper
2022-05-09  9:26 ` Florian Weimer
2022-05-09 10:04   ` Ulrich Drepper
2022-05-09 10:07   ` Andreas Schwab
2022-05-10 13:27     ` Jonathan Wakely
2022-05-10 17:48       ` Tom Honermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).