This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Zero-length arrays
- To: drepper at cygnus dot com, drepper at redhat dot com
- Subject: Re: Zero-length arrays
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Thu, 04 Jan 2001 14:04:08 -0800
- Cc: rth at redhat dot com, torvalds at transmeta dot com, gcc-patches at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <m3lmsrqd8w.fsf@otr.mynet.cygnus.com>
Richard Henderson <rth@redhat.com> writes:
> Actually, I was talking about this in the context of allowing
>
> struct f {
> int w;
> int x[];
> } f = { 1, { 2, 3, 4 } };
>
> but disallowing
>
> struct f {
> int w;
> int x[0];
> } f = { 1, { 2, 3, 4 } };
>
> since "clearly" X has zero elements.
I admit to liking this proposal a lot. I think it's very appealing
from a language lawyer point of view.
I belive that Richard's proposal has no impact on the GCC extension of
a variable-sized array declared with the `[0]' notation *when
allocated on the heap*. Instead, we're only talking about the
statically initialized case.
That's got to be pretty rare -- it's not ANSI/ISO C, and most people
would use the correct bounds, if they're doing a static
initialization.
The usual heavy extension users are the Linux kernel and the C
library. Do y'all actually do this kind of initialization for
statically allocated objects?
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com