public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic
@ 2014-05-20 18:40 bugs at qult dot net
  2014-05-20 19:01 ` [Bug c++/61259] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bugs at qult dot net @ 2014-05-20 18:40 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-02-20  8:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-20 18:40 [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic bugs at qult dot net
2014-05-20 19:01 ` [Bug c++/61259] " redi at gcc dot gnu.org
2015-10-21 21:38 ` ilja.j.honkonen at nasa dot gov
2021-04-20  7:57 ` [Bug c++/61259] [Regression 8/9/10/11] " reichelt at gcc dot gnu.org
2021-04-30  9:19 ` [Bug c++/61259] [8/9/10/11/12 Regression] " rguenth at gcc dot gnu.org
2021-05-14  9:47 ` [Bug c++/61259] [9/10/11/12 " jakub at gcc dot gnu.org
2021-06-01  8:06 ` rguenth at gcc dot gnu.org
2022-05-27  9:35 ` [Bug c++/61259] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:30 ` jakub at gcc dot gnu.org
2023-07-07 10:30 ` [Bug c++/61259] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-02-20  8:55 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).