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

* [Bug c++/61259] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  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 ` redi at gcc dot gnu.org
  2015-10-21 21:38 ` ilja.j.honkonen at nasa dot gov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-20 19:01 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-05-20
      Known to work|                            |4.3.6
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The warning has been given since GCC 4.4 (but not earlier)


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

* [Bug c++/61259] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  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
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ilja.j.honkonen at nasa dot gov @ 2015-10-21 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

ilja.j.honkonen at nasa dot gov changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ilja.j.honkonen at nasa dot gov

--- Comment #2 from ilja.j.honkonen at nasa dot gov ---
I'm seeing this also, when I create an ofstream with () instead of {} I get a
complaint from gcc-4.4 to gcc-5:

#include "vector"
#include "string"
#include "fstream"
#include "boost/filesystem.hpp"
int main() {
        std::vector<std::string> input_files{"a.out"};
        std::ofstream str(
        //std::ofstream str{
                boost::filesystem::path(input_files[0])
                        .parent_path()
                        .append("b")
                        .generic_string()
        );
        //};
}

g++-mp-4.9 gcc.cpp -I $HOME/include -L $HOME/lib -lboost_filesystem
-lboost_system -std=c++0x -W -Wall -Wextra -pedantic -O3
gcc.cpp: In function 'int main()':
gcc.cpp:9:41: warning: ISO C++ forbids zero-size array 'input_files'
[-Wpedantic]
   boost::filesystem::path(input_files[0])
                                         ^

g++-mp-4.4 gcc.cpp -I $HOME/include -L $HOME/lib -lboost_filesystem
-lboost_system -std=c++0x -W -Wall -Wextra -pedantic -O3
gcc.cpp: In function 'int main()':
gcc.cpp:9: warning: ISO C++ forbids zero-size array 'input_files'


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

* [Bug c++/61259] [Regression 8/9/10/11] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  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 ` 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
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: reichelt at gcc dot gnu.org @ 2021-04-20  7:57 UTC (permalink / raw)
  To: gcc-bugs

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

Volker Reichelt <reichelt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.3.0, 4.4.0
                 CC|                            |reichelt at gcc dot gnu.org
            Summary|Spurious "ISO C++ forbids   |[Regression 8/9/10/11]
                   |zero-size array" warning    |Spurious "ISO C++ forbids
                   |with -pedantic              |zero-size array" warning
                   |                            |with -pedantic
   Last reconfirmed|2014-05-20 00:00:00         |2021-4-20
           Keywords|                            |rejects-valid

--- Comment #4 from Volker Reichelt <reichelt at gcc dot gnu.org> ---
If you compile the code with "-pedantic-errors" the code is wrongly rejected,
so marking it as rejects-valid.

Self-contained example:

==============================
int foo(int x[2])
{
  int i(int(x[0])*1);
  return i;
}
==============================

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

* [Bug c++/61259] [8/9/10/11/12 Regression] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  2014-05-20 18:40 [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic bugs at qult dot net
                   ` (2 preceding siblings ...)
  2021-04-20  7:57 ` [Bug c++/61259] [Regression 8/9/10/11] " reichelt at gcc dot gnu.org
@ 2021-04-30  9:19 ` rguenth at gcc dot gnu.org
  2021-05-14  9:47 ` [Bug c++/61259] [9/10/11/12 " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-30  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[Regression 8/9/10/11]      |[8/9/10/11/12 Regression]
                   |Spurious "ISO C++ forbids   |Spurious "ISO C++ forbids
                   |zero-size array" warning    |zero-size array" warning
                   |with -pedantic              |with -pedantic
           Priority|P3                          |P2
   Target Milestone|---                         |8.5

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

* [Bug c++/61259] [9/10/11/12 Regression] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  2014-05-20 18:40 [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic bugs at qult dot net
                   ` (3 preceding siblings ...)
  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 ` jakub at gcc dot gnu.org
  2021-06-01  8:06 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14  9:47 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.5                         |9.4

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.

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

* [Bug c++/61259] [9/10/11/12 Regression] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  2014-05-20 18:40 [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic bugs at qult dot net
                   ` (4 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug c++/61259] [10/11/12/13 Regression] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  2014-05-20 18:40 [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic bugs at qult dot net
                   ` (5 preceding siblings ...)
  2021-06-01  8:06 ` rguenth at gcc dot gnu.org
@ 2022-05-27  9:35 ` rguenth at gcc dot gnu.org
  2022-06-28 10:30 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug c++/61259] [10/11/12/13 Regression] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  2014-05-20 18:40 [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic bugs at qult dot net
                   ` (6 preceding siblings ...)
  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
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug c++/61259] [11/12/13/14 Regression] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  2014-05-20 18:40 [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic bugs at qult dot net
                   ` (7 preceding siblings ...)
  2022-06-28 10:30 ` jakub at gcc dot gnu.org
@ 2023-07-07 10:30 ` rguenth at gcc dot gnu.org
  2024-02-20  8:55 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

* [Bug c++/61259] [11/12/13/14 Regression] Spurious "ISO C++ forbids zero-size array" warning with -pedantic
  2014-05-20 18:40 [Bug c++/61259] New: Spurious "ISO C++ forbids zero-size array" warning with -pedantic bugs at qult dot net
                   ` (8 preceding siblings ...)
  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
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20  8:55 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janschultke at googlemail dot com

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 114006 has been marked as a duplicate of this bug. ***

^ 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).