From: Ulrich Drepper <drepper@redhat.com>
To: gcc@gcc.gnu.org
Subject: -Wformat and u8""
Date: Mon, 9 May 2022 11:15:44 +0200 [thread overview]
Message-ID: <CAP3s5k93syRYr6v198OBxYgSHajmeZPWc7BNPxxc=WxF9Evpqg@mail.gmail.com> (raw)
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.
next reply other threads:[~2022-05-09 9:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 9:15 Ulrich Drepper [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP3s5k93syRYr6v198OBxYgSHajmeZPWc7BNPxxc=WxF9Evpqg@mail.gmail.com' \
--to=drepper@redhat.com \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).