This is the mail archive of the
mailing list for the GDB project.
Re: format string is not a string literal
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Jack Howarth <howarth dot mailing dot lists at gmail dot com>
- Cc: Simon Marchi <simon dot marchi at polymtl dot ca>, "Paul_Koning at dell dot com" <Paul_Koning at dell dot com>, "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Thu, 26 Feb 2015 00:46:41 -0800
- Subject: Re: format string is not a string literal
- Authentication-results: sourceware.org; auth=none
- References: <CADtEn-1ZT1uznxPzQxr_nBQya1AVrNLyE+ZSDmm2x_ux8qyzUQ at mail dot gmail dot com> <0AB56024-875B-4724-8ED2-A9DDB237CBFF at dell dot com> <CADtEn-0txdtq6x6dAZZ5wew-VOvYU28fueT_kJ2cx7=H0=vdPg at mail dot gmail dot com> <23CC7871-C616-436C-920C-4A635DC87189 at dell dot com> <CAFXXi0=56gNf2GoSKkrx=bRArhjk+AhSbiu0crpdR3=df7B2BQ at mail dot gmail dot com> <7A311B56-C424-4C4F-A0E4-B12B65131745 at gmail dot com> <CADtEn-1vHnay=ftK9Hq6ogYyDNPc_anNgLnwuUZSt4VjzF+7GQ at mail dot gmail dot com> <225BDA7A-3A1F-4F94-8086-E44249E273D5 at gmail dot com> <CAFXXi0kTXpo++fHcTkWHbAT9sH_pG5ZtgeFf-2RQqZZigzdmdw at mail dot gmail dot com> <CA+=Sn1n=pkwD01uooGuTKgcMEQsS=LKE9fKvfEQ+j2f+jwaM3w at mail dot gmail dot com> <CA+=Sn1mGhjnxuBL2KExPOoAZz05-hh=qAkTdvQ1S=66dvUZuqw at mail dot gmail dot com> <CADtEn-0Z8crk6KQt4cN8scGOOonCfYwKHxq0ga2FKy0Dew4qaQ at mail dot gmail dot com>
On Thu, Feb 26, 2015 at 12:39 AM, Jack Howarth
> On Wed, Feb 25, 2015 at 9:38 PM, Andrew Pinski <email@example.com> wrote:
>> On Wed, Feb 25, 2015 at 6:35 PM, Andrew Pinski <firstname.lastname@example.org> wrote:
>>> On Wed, Feb 25, 2015 at 6:30 PM, Simon Marchi <email@example.com> wrote:
>>>>>> On Feb 25, 2015, at 4:41 PM, Jack Howarth <firstname.lastname@example.org> wrote:
>>>>>> See the additional comments from the llvm.org clang developers at...
>>>>> Then put this warning under a different flag. Anyways clang is broken and gdb should not change due to a broken compiler.
>>>> I would not say that clang is broken or that the warning is unclear.
>>>> The flag is -Wformat-nonliteral and the warning message is "format
>>>> string is not a string literal". I don't know how you can be more
>>>> clear and direct about the fact that the format string is not a string
>>>> literal. Looking at the code, we observe that clang is right (the
>>>> format string is indeed not a string literal). With the proper
>>>> function attributes, the compiler could do better checks and prevent
>>>> programming mistakes. Since clang pointed out this low-hanging fruit
>>>> improvement to gdb's code, why shouldn't we take advantage of it?
>>>> Anyway, Jack, you are welcome to submit a patch for this if you feel
>>>> like it and/or file a bug if it is not already done.
>>> Except GCC documents this options differently than clang implements:
>>> -Wformat-nonliteralIf -Wformat is specified, also warn if the format
>>> string is not a string literal and so cannot be checked, unless the
>>> format function takes its format arguments as a va_list.
>>> Notice the last part of the documentation.
>>> So this again is clang implements a GCC option but does not follow the
>>> documentation of GCC.
>>> How does clang document this option?
>> GCC has always documented this option this way since at least 3.1.1:
>> And there is no user documentation for clang for this option so clang is broken.
Who would have thought to look into the documentation part of the
attribute for option documentation :).
Anyways this is an documented incompatibility which means gdb should
just test if it is being compiled with clang, not add the option.
Or better yet people should push back to clang that they need to
separate out the option or have an option to be GCC compatible.