Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!ima!haddock!karl From: karl@haddock.UUCP Newsgroups: comp.lang.c,comp.lang.c++ Subject: Bounds checking (Was: segments and Unix) Message-ID: <180@haddock.UUCP> Date: Tue, 2-Dec-86 21:29:51 EST Article-I.D.: haddock.180 Posted: Tue Dec 2 21:29:51 1986 Date-Received: Wed, 3-Dec-86 05:48:09 EST References: <13802@amdcad.UUCP> <3950002@nucsrl.UUCP> Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer) Organization: Interactive Systems, Boston Lines: 18 Summary: C++ method isn't transparent Xref: watmath comp.lang.c:222 comp.lang.c++:56 In article <3950002@nucsrl.UUCP> gore@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@haddock.isc.com), The Walking Lint (I've added the c++ newsgroup; be careful if you followup.)