Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!princeton!phoenix!tbrakitz From: tbrakitz@phoenix.Princeton.EDU (Triantaphyllos Byron Rakitzis) Newsgroups: comp.lang.c Subject: Re: Zero Length Arrays Allowed in C Standard? Message-ID: <11963@phoenix.Princeton.EDU> Date: 5 Dec 89 19:52:09 GMT References: <2298@jato.Jpl.Nasa.Gov> <11715@smoke.BRL.MIL> <480@codonics.COM> <1989Dec2.210042.12668@twwells.com> <8129@cg-atla.UUCP> <1989Dec5.112553.24087@twwells.com> Organization: Princeton University, NJ Lines: 27 In-reply-to: bill@twwells.com's message of 5 Dec 89 11:25:53 GMT Bill Wells says: >This still can waste memory, because of padding in the size of >SYMTAB. Moreover, some systems might take that [1] declaration >seriously and give you an error when you access something beyond >the first element of the string. The kind that immediately comes >to mind is debugging interpreters: these, one hopes, will check >for accessing outside the bounds of an array. Wait, hold on a second. If an implementation of C does bounds checking then it isn't C any more. That's not how C works. There's no such thing as an array in C. Just pointers, and memory. It's up to the system to do segementation protection, if it wants. Byron Rakitzis (Honestly, I don't see any problem with declaring an array [1] and then subtracting one from the malloc() call. Really, what's the problem? How can this be a waste of memory? You never have a zero-byte string! C strings are always terminated with a '\0' anyway!!) -- "C Code." "C Code run." "Run, Code, run!" Byron Rakitzis. (tbrakitz@phoenix.princeton.edu ---- tbrakitz@pucc.bitnet)