[llvm] r216344 - Silence gcc -Wpedantic.

David Blaikie dblaikie at gmail.com
Mon Sep 15 11:15:43 PDT 2014


On Mon, Sep 15, 2014 at 1:41 AM, Patrik Hägglund H <
patrik.h.hagglund at ericsson.com> wrote:

>  > Does this warning go away if you instead write the code as:
>
> >
>
> >   std::string Invocation = std::string(argv[0]) + " " + argv[1];
>
>
>
> Yes, the warning goes away. (And I must confess that I didn’t understood
> this warning. Your guess seems plausible. Do you want any further changes
> to be committed?)
>

If you could commit the above change - it makes the code simpler & clearer
while avoiding the warning.

I don't really understand what GCC's doing that it's so confused as to
/warn/ on this code, yet successfully compile it.  I'd almost be inclined
to disable the warning & rely on Clang's. But happy for you to continue
cleaning up other code where this warning fires (if there is) in the way I
showed above, ideally - otherwise we should discuss what the cleanup looks
like, whether it's an improvement, and likely disable the warning if it's
actively harming readability.

- David


>
>
> /Patrik Hägglund
>
>
>
> *From:* David Blaikie [mailto:dblaikie at gmail.com]
> *Sent:* den 12 september 2014 20:10
>
> *To:* Patrik Hägglund H
> *Cc:* llvm-commits at cs.uiuc.edu
> *Subject:* Re: [llvm] r216344 - Silence gcc -Wpedantic.
>
>
>
>
>
>
>
> On Fri, Sep 12, 2014 at 11:01 AM, Patrik Hägglund H <
> patrik.h.hagglund at ericsson.com> wrote:
>
> > What was the particular warning here?
>
>
>
> ../tools/llvm-cov/llvm-cov.cpp:53:49: error: ISO C++ forbids zero-size
> array 'argv' [-Werror=pedantic]
>
>        std::string Invocation(std::string(argv[0]) + " " + argv[1]);
>
>
>
> Wait, what... (sorry, not "what"ing you, I'm "what"ing GCC). Is GCC's
> warning getting confused and thinking 'argv' is a declaration here? (yet
> then going on to correctly parse this as an expression?
>
> Does this warning go away if you instead write the code as:
>
>   std::string Invocation = std::string(argv[0]) + " " + argv[1];
>
> ?
>
>
>
>
>
> *From:* David Blaikie [mailto:dblaikie at gmail.com]
> *Sent:* den 24 augusti 2014 23:15
> *To:* Patrik Hägglund H
> *Cc:* llvm-commits at cs.uiuc.edu
> *Subject:* Re: [llvm] r216344 - Silence gcc -Wpedantic.
>
>
>
>
> On Aug 24, 2014 1:05 PM, "Patrik Hagglund" <patrik.h.hagglund at ericsson.com>
> wrote:
> >
> > Author: patha
> > Date: Sun Aug 24 04:12:33 2014
> > New Revision: 216344
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=216344&view=rev
> > Log:
> > Silence gcc -Wpedantic.
>
> What was the particular warning here?
>
> >
> > Modified:
> >     llvm/trunk/tools/llvm-cov/llvm-cov.cpp
> >
> > Modified: llvm/trunk/tools/llvm-cov/llvm-cov.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/llvm-cov.cpp?rev=216344&r1=216343&r2=216344&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/tools/llvm-cov/llvm-cov.cpp (original)
> > +++ llvm/trunk/tools/llvm-cov/llvm-cov.cpp Sun Aug 24 04:12:33 2014
> > @@ -50,7 +50,7 @@ int main(int argc, const char **argv) {
> >        func = gcov_main;
> >
> >      if (func) {
> > -      std::string Invocation(std::string(argv[0]) + " " + argv[1]);
> > +      std::string Invocation(std::string() + argv[0] + " " + argv[1]);
> >        argv[1] = Invocation.c_str();
> >        return func(argc - 1, argv + 1);
> >      }
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140915/420f7982/attachment.html>


More information about the llvm-commits mailing list