On Mon, 9 May 2022 at 11:09, Andreas Schwab wrote: > > On Mai 09 2022, Florian Weimer via Gcc wrote: > > > * Ulrich Drepper via Gcc: > > > >> 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); > >> | ^~~~~~~~~~~~~ > > > > This is not an aliasing violation because of the exception for char, > > right? So the warning does not even highlight theoretical undefined > > behavior. > > > > On the other hand, that cast is still quite ugly. All string-related > > functions in the C library currently need it. It might obscure real > > type errors. Isn't this a problem with char8_t? > > In C++20, u8 literals have a distinct type, which is an incompatible > change from C++17.
And the recommended way to deal with it is to use a cast as Ulrich did.