[llvm] r216344 - Silence gcc -Wpedantic.

David Blaikie dblaikie at gmail.com
Fri Sep 12 11:10:00 PDT 2014


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/20140912/77d8e5ea/attachment.html>


More information about the llvm-commits mailing list