[Bug c++/105626] New: -Wformat should accept u8"" strings
drepper.fsp+rhbz at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue May 17 12:13:41 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105626
Bug ID: 105626
Summary: -Wformat should accept u8"" strings
Product: gcc
Version: 12.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: ---
The discussion about this topic on gcc@
(https://gcc.gnu.org/pipermail/gcc/2022-May/238673.html) ended with the
conclusion that gcc should not disregard the cast in code like this:
#include <stdio.h>
int main()
{
printf((const char*) u8"test %d\n", 1);
return 0;
}
With -Wformat this code produces with gcc 12:
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);
| ^~~~~~~~~~~~~
Since
a) there are no I/O functions for u8 strings in C++20
b) using u8 strings is necessary in reliable code
c) it is safe to perform the analysis -Wformat does on u8 strings
I suggest that u8 strings are allowed when testing for -Wformat.
More information about the Gcc-bugs
mailing list