Path: utzoo!utgpu!watmath!clyde!att!osu-cis!killer!usl!ralph!pja From: pja@ralph.UUCP (Pete Alleman) Newsgroups: comp.lang.c Subject: Re: Run-time Checks for C Message-ID: <366@ralph.UUCP> Date: 26 Nov 88 18:05:30 GMT References: <10113@umn-cs.CS.UMN.EDU> Reply-To: pja@ralph.UUCP (Pete Alleman) Organization: Home Sweet Home, Lafayette, LA Lines: 24 In article <10113@umn-cs.CS.UMN.EDU> raghavan@umn-cs.cs.umn.edu (Vijay Raghavan) writes: >the C language definition doesn't really preclude any implementation from >doing certain run-time checks (for array bounds, type checking, referring >contents of uninitialized pointer variables &c), The real problem with bounds checking in C is that the implementation is difficult (if not impossible). Most high-level languages allow only very limited pointer arithmetic (array indexing on arrays with known bounds). Bounds checking in C might be possible is a pointer contained 3 values: The memory address, an upper bound, and a lower bound. Pointer arithmetic would modify only the current value. Assignment would copy all 3 values. Can anyone find a flaw in this type of implementation? >it's just that most >(okay, all!) implementations don't do any such checking because of efficiency >reasons. I vaguely remember seeing a flyer for a C interpreter that claimed to check bounds. -- Pete Alleman ralph!pja or digitran!pja