[Bug c/101446] -Wpedantic causes an error with zero size array

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 14 09:46:38 GMT 2021


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-07-14
             Status|RESOLVED                    |NEW
                 CC|                            |jsm28 at gcc dot gnu.org
         Resolution|INVALID                     |---
     Ever confirmed|0                           |1

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so the complaint is that

> ./cc1 -quiet t.c -pedantic
t.c:1:47: warning: ISO C forbids empty initializer braces [-Wpedantic]
    1 | static const char __gbk_from_ucs4_tab9[][2] = {};
      |                                               ^
t.c:1:19: error: zero or negative size array '__gbk_from_ucs4_tab9'
    1 | static const char __gbk_from_ucs4_tab9[][2] = {};
      |                   ^~~~~~~~~~~~~~~~~~~~

errors and not only -pedantic-errors

> ./cc1 -quiet t.c -pedantic-errors
t.c:1:47: error: ISO C forbids empty initializer braces [-Wpedantic]
    1 | static const char __gbk_from_ucs4_tab9[][2] = {};
      |                                               ^
t.c:1:19: error: zero or negative size array '__gbk_from_ucs4_tab9'
    1 | static const char __gbk_from_ucs4_tab9[][2] = {};
      |                   ^~~~~~~~~~~~~~~~~~~~

-Wpedantic is just an alias for -pedantic - but see the documentation which
explicitely says some constructs are rejected (not only warned on).
-pedantic-errors says

@item -pedantic-errors
@opindex pedantic-errors
Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
requires a diagnostic, in some cases where there is undefined behavior
at compile-time and in some other cases that do not prevent compilation
of programs that are valid according to the standard. This is not
equivalent to @option{-Werror=pedantic}, since there are errors enabled
by this option and not enabled by the latter and vice versa.

so I still think it works as designed even if the new -Wpedantic alias
suggests that -pedantic is a pure warning option.


More information about the Gcc-bugs mailing list