This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: wrong excess elements warning
- To: Ulrich Drepper <drepper at cygnus dot com>
- Subject: Re: wrong excess elements warning
- From: Graham Stott <grahams at redhat dot com>
- Date: Wed, 01 Nov 2000 19:46:42 +0000
- CC: gcc-bugs at gcc dot gnu dot org
- References: <m38zr37dq9.fsf@otr.mynet.cygnus.com>
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