This is the mail archive of the gcc-patches@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: Zero-length arrays


Richard Henderson <rth@redhat.com> writes:

> You write 
> 	int array[] = { 0, 1, 2 };
> not
> 	int array[0] = { 0, 1, 2 };
> 
> If
> 	int array[1] = { 0, 1, 2 };
> yields an "excess elements in array" warning why doesn't
> 	int array[0] = { 0, 1, 2 };
> 
> (And, incidentally, we _don't_ yield such a warning even when
> the array is at top-level.  This should be addressed.)
> 
> Uli, do you think you could live with this sort of change?

You mean disallowing a zero array size and disallowing the number of
initializers being greater than the given array size?  This is of
course OK, we never consciously did this.  If you want the initializers decide about the number of elements use [] and not [0].

-- 
---------------.                          ,-.   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]