Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: C run-time checking Message-ID: <10651@mimsy.UUCP> Date: 15 Mar 88 13:57:36 GMT References: <763@uvm-gen.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 27 Keywords: C arrays pointers run-time-checking In article <763@uvm-gen.UUCP> hartley@uvm-gen.UUCP (Stephen J. Hartley) writes: >... Are there C compilers provided by any vendors that generate code >to perform run-time checking ... such as checking an array subscript >against the array bounds, checking a pointer for reasonable values >before dereferencing it. I have heard of two such compilers; one is called Safe-C and I cannot recall the name of the other. For some reason this is tied in with a memory of a C interpreter that can dynamically either interpret or compile code: a handy thing to have if you ever write buggy code :-) . In general, pointer and array checking in C is difficult but not impossible. Every pointer must carry around three values (min, max, and current), and some operations must be allowed while others must be prevented. E.g., the dpANS says that int foo[MAX], *p; for (p = &foo[0]; p < &foo[MAX]; p++) is legal; hence, computing the address of foo[MAX] must be allowed, while actually indirecting through *(foo+MAX) must not. At least one of those runtime-checking systems forced one to write for (p = &foo[0]; p <= &foo[MAX - 1]; p++) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris