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.

Reply via email to