Path: utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!ucsd!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!bu.edu!snorkelwacker!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!edcastle!aiai!richard From: richard@aiai.ed.ac.uk (Richard Tobin) Newsgroups: comp.lang.c Subject: Re: Array bounds checking with C???? Message-ID: <3337@skye.ed.ac.uk> Date: 31 Aug 90 12:11:30 GMT References: <7611@ucdavis.ucdavis.edu> <26196@mimsy.umd.edu> <988@christopher-robin.cs.bham.ac.uk> Reply-To: richard@aiai.UUCP (Richard Tobin) Organization: AIAI, University of Edinburgh, Scotland Lines: 18 In article <988@christopher-robin.cs.bham.ac.uk> cjr@christopher-robin.UUCP (Chris Ridd ) writes: >>I had heard it still objected to `&arr[sizeof arr/sizeof *arr]', >>which is Officially Legal. > Why is this? I never could figure out why accessing the first >element *past* the end of an array should be legal. Because it's not *accessing* it. Note the ampersand. It's very useful for loops: for(p = buf; p < &buf[sizeof(buf)]; p++) -- Richard -- Richard Tobin, JANET: R.Tobin@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin