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:

  > 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

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