This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61259

            Bug ID: 61259
           Summary: Spurious "ISO C++ forbids zero-size array" warning
                    with -pedantic
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugs at qult dot net

The following code, when compiled with -pedantic, compiles properly but
produces a warning about zero-sized array 'argv'.

#include <iostream>

struct Foo {
  Foo(const char* s) : p(s) {}
  const char*    p;
};

int main(int, char* argv[])
{
  const char*    s(Foo(argv[0]).p);
  std::cout << s << std::endl;
  return 0;
}

I understand that const char* s(Foo(argv[0])) is to be understood as being a
declaration of function s taking an array of 0 Foo and returning a const char*,
but with the '.p', apparently the compiler resolves the ambiguity by itself and
the code does build an instance of Foo with argv[0] as an argument.

So in any case, something's wrong: either this code should not compile or it
should not issue the warning.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]