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]

wrong excess elements warning


gcc recently started to warn incorrectly about something like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ cat u.c
struct
{
  int n;
  int a[0];
} foo =
{
  10,
  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
};
$ gcc -c u.c
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
u.c:8: warning: excess elements in array initializer
u.c:8: warning: (near initialization for `foo.a')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Arrays of Zero Length are a documented and often used gcc extension.
The warning must only be give if -pedantic is used.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

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