From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26314 invoked by alias); 26 Feb 2015 08:46:47 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 26297 invoked by uid 89); 26 Feb 2015 08:46:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.5 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-lb0-f177.google.com Received: from mail-lb0-f177.google.com (HELO mail-lb0-f177.google.com) (209.85.217.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 26 Feb 2015 08:46:44 +0000 Received: by lbjf15 with SMTP id f15so9231419lbj.13 for ; Thu, 26 Feb 2015 00:46:41 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.152.178.164 with SMTP id cz4mr6305557lac.39.1424940401240; Thu, 26 Feb 2015 00:46:41 -0800 (PST) Received: by 10.25.21.213 with HTTP; Thu, 26 Feb 2015 00:46:41 -0800 (PST) In-Reply-To: References: <0AB56024-875B-4724-8ED2-A9DDB237CBFF@dell.com> <23CC7871-C616-436C-920C-4A635DC87189@dell.com> <7A311B56-C424-4C4F-A0E4-B12B65131745@gmail.com> <225BDA7A-3A1F-4F94-8086-E44249E273D5@gmail.com> Date: Thu, 26 Feb 2015 10:18:00 -0000 Message-ID: Subject: Re: format string is not a string literal From: Andrew Pinski To: Jack Howarth Cc: Simon Marchi , "Paul_Koning@dell.com" , "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00064.txt.bz2 On Thu, Feb 26, 2015 at 12:39 AM, Jack Howarth wrote: > On Wed, Feb 25, 2015 at 9:38 PM, Andrew Pinski wrote: >> On Wed, Feb 25, 2015 at 6:35 PM, Andrew Pinski wrote: >>> On Wed, Feb 25, 2015 at 6:30 PM, Simon Marchi wrote: >>>>>> On Feb 25, 2015, at 4:41 PM, Jack Howarth wrote: >>>>>> >>>>>> Andrew, >>>>>> See the additional comments from the llvm.org clang developers at... >>>>>> >>>>>> http://llvm.org/bugs/show_bug.cgi?id=22701#c5 >>>>> >>>>> Then put this warning under a different flag. Anyways clang is broken and gdb should not change due to a broken compiler. >>>>> >>>>> Thanks, >>>>> Andrew >>>> >>>> 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: >> https://gcc.gnu.org/onlinedocs/gcc-3.1.1/gcc/Warning-Options.html#Warning%20Options >> >> And there is no user documentation for clang for this option so clang is broken. > > http://clang.llvm.org/docs/AttributeReference.html#format-gnu-format 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. Thanks, Andrew > >> >> Thanks, >> Andrew >> >> >> >>> Thanks, >>> Andrew >>> >>>> >>>> Simon