Re: format string is not a string literal

Paul_Koning
2015-02-25T23:36:31Z

> On Feb 25, 2015, at 6:21 PM, Jack Howarth <howarth.mailing.lists@gmail.com> wrote:
>
> Paul,
> The clang developers disagree...
>
> http://llvm.org/bugs/show_bug.cgi?id=22701#c3
>
> Jack
>
> On Tue, Feb 24, 2015 at 1:09 PM, <Paul_Koning@dell.com> wrote:
>>
>>> On Feb 24, 2015, at 12:13 PM, Jack Howarth <howarth.mailing.lists@gmail.com> wrote:
>>>
>>> Building gdb 7.9 on x86_64-apple-darwin14 produces a number of
>>> warnings from -Wformat-nonliteral...
>>
>> Sounds like it’s time to turn off that warning, since the code is legit.
>>
>> paul

I didn’t say it’s a bug, Andrew did. But I agree with him.

My comment (“the code is legit”) simply meant that GDB uses variable formats for obvious valid reasons (so the format can vary, being user-supplied). Given that it’s intentional, the warning is not wanted.

But that point is really applicable to printf, not vprintf. Andrew’s point is that checking formats for vprintf is not possible because you can’t know the argument list; only in printf do you see the arguments so you can match the types. So the bug is that format checking and complaining for non-literal formats should not be enabled at all for vprintf. That may be a header issue rather than a compiler issue, but either way, it’s not the right thing to do.

paul