From: Pedro Alves <palves@redhat.com>
To: Michael Eager <eager@eagerm.com>,
Simon Marchi <simon.marchi@ericsson.com>,
gdb-patches@sourceware.org
Subject: Re: [pushed] microblaze-tdep: Add ATTRIBUTE_PRINTF to microblaze_debug
Date: Mon, 25 Sep 2017 16:06:00 -0000 [thread overview]
Message-ID: <441bab33-67b9-be36-e4b7-c22e6936a7bf@redhat.com> (raw)
In-Reply-To: <078ea0b6-71aa-f74d-33fc-859322d4668a@eagerm.com>
On 09/25/2017 03:14 PM, Michael Eager wrote:
> On 09/21/2017 05:11 AM, Simon Marchi wrote:
>> I am getting this warning with clang:
>>
>> /home/emaisin/src/binutils-gdb/gdb/microblaze-tdep.c:94:28: error:
>> format string is not a string literal [-Werror,-Wformat-nonliteral]
>> vprintf_unfiltered (fmt, args);
>> ^~~
>>
>> Adding ATTRIBUTE_PRINTF to microblaze_debug gets rid of it. Strangely,
>> > gcc doesn't warn about non-literal format strings when calling vprintf
>> (or a vprintf-style function, like vprintf_unfiltered). I filed this
>> gcc bug:
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206
>
> I'll admit to not being familiar with the nuances of __attribute__
> ((format ...)),
> or why adding this to the function declaration of microblaze_debug()
> would suppress
> a diagnostic on the call to vprintf_unfiltered(),
Because with that the compiler can assume that the 'fmt' argument
as passed down to microblaze_debug is a string literal. I.e.,
the compiler can tell that the argument to vprintf_unfiltered is
itself transitively a string literal.
> but the better fix
> seems to me to
> be to turn off the obviously inappropriate -Wformat-nonliteral option in
> microblaze_debug() using
> #pragma GCC diagnostic ignored "-Wformat-nonliteral"
That doesn't make sense to me.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2017-09-25 16:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-21 12:11 Simon Marchi
2017-09-25 14:14 ` Michael Eager
2017-09-25 16:06 ` Pedro Alves [this message]
2017-09-25 16:43 ` Michael Eager
2017-09-25 17:09 ` Pedro Alves
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=441bab33-67b9-be36-e4b7-c22e6936a7bf@redhat.com \
--to=palves@redhat.com \
--cc=eager@eagerm.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.com \
/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