Zero Length Arrays Allowed in C Standard?

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Dec 7 02:16:33 AEST 1989


In article <11963 at phoenix.Princeton.EDU> tbrakitz at phoenix.Princeton.EDU (Triantaphyllos Byron Rakitzis) writes:
-Bill Wells says:
->... 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.

Wrong.

-That's not how C works. There's no such thing as an array in C.
-Just pointers, and memory.

Wrong.

-It's up to the system to do segementation protection, if it wants. 

Not relevant.

Just because you aren't familiar with an implementation like Bill
described does not mean they don't exist or that they're not valid
C implementations.

I use the [1] kludge on occasion, but I raise flags when I do because
it is not guaranteed to work.  It happens to, on all the systems I
commonly have access to.



More information about the Comp.lang.c mailing list