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]

Re: wrong excess elements warning


Ulrich

Ulrich Drepper wrote:
> 
> gcc recently started to warn incorrectly about something like
> 
why incorrectly?

 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> $ 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.

Yes arrays of zero length are documented., but it was never documented 
that they could be statically initialised. This is yet another poorly
documented GCC extension.

Richard would you care to add your $0.02 here.

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


Graham

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