Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!ncar!noao!arizona!gudeman From: gudeman@cs.arizona.edu (David Gudeman) Newsgroups: comp.lang.misc Subject: Re: Answers, Chapter 1: TeX (was C's sins... and others) Message-ID: <26740@megaron.cs.arizona.edu> Date: 24 Oct 90 09:00:30 GMT Organization: U of Arizona CS Dept, Tucson Lines: 31 In article <3681@lanl.gov> jlg@lanl.gov (Jim Giles) writes: ][I argue that pointers are bounded just like arrays] ]Really? I don't know _any_ language that has pointers that places ]bounds on where it can point. We are comparing pointers to indexes here. The only time these two are comparable is when the pointer is one that was calculated with integer addition on a pointer to an array. An out-of-bounds pointer --in correspondence to an out-of-bounds index-- is a pointer whose value is not in the same array as the starting pointer. ]What you are talking about here is the ANSI C (which is _very_ new) ]constraint on the validity of pointer _arithmetic_. This constraint ]merely says that comparing (or subtracting) pointers that currently ]point to within separately allocated objects is undefined. No, I'm talking about C in general. And of course I'm talking about pointer arithmetic, otherwise there is no correspondence between indexes and pointers. I don't believe any definition of C has ever defined the effect of dereferencing a pointer that was miscalculated so that it points out of the region the starting array. However, C _could_ define this as producing an error, and then pointer bounds checking would be just as safe and reliable as array index bounds checking. This is all starting to sound very familiar... -- David Gudeman Department of Computer Science The University of Arizona gudeman@cs.arizona.edu Tucson, AZ 85721 noao!arizona!gudeman