Bounds checking (Was: segments and Unix)

karl at haddock.UUCP karl at haddock.UUCP
Wed Dec 3 12:29:51 AEST 1986


In article <3950002 at nucsrl.UUCP> gore at nucsrl.UUCP (Jacob Gore) writes:
>[Putting each object in its own segment won't be accepted by hardware
>vendors.] Besides, there is a neat and simple software solution.  It is used
>in C++, which, hopefully, will replace C eventually:  You can define a class
>of arrays that always check that the index is within the boundaries.  Arrays
>in this class are used in exactly the same way as normal arrays are used, so
>it does not change the appearance of the program.

I don't think so.  I know I can declare a class intarray, which includes the
bounds as well as the address, and I can dereference an instance of it with
"*a" or "a[i]", and in the newer versions of C++ I can use it in a context
that expects "int *" -- but if I have to declare it "intarray a" instead of
"int *a" (or "intarray a(SIZ)" instead of "int a[SIZ]"), then it does change
the appearance of the program.  I've heard there is a preprocessor that will
insert run-time bounds checking into C code, but it's not C++.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
(I've added the c++ newsgroup; be careful if you followup.)



More information about the Comp.lang.c mailing list