Run-time Checks for C

Pete Alleman pja at ralph.UUCP
Sun Nov 27 04:05:30 AEST 1988


In article <10113 at umn-cs.CS.UMN.EDU> raghavan at 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



More information about the Comp.lang.c mailing list