Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!uw-june!pardo From: pardo@june.cs.washington.edu (David Keppel) Newsgroups: comp.lang.c Subject: Re: C run-time checking Message-ID: <4465@june.cs.washington.edu> Date: 15 Mar 88 23:39:23 GMT References: <763@uvm-gen.UUCP> Reply-To: pardo@uw-june.UUCP (David Keppel) Organization: U of Washington, Computer Science, Seattle Lines: 33 Keywords: C arrays pointers run-time-checking In article <763@uvm-gen.UUCP> hartley@uvm-gen (Stephen J. Hartley) writes: > > I scan this news group every day but don't remember ever seeing a >discussion about this. Are there C compilers provided by any >vendors that generate code to perform run-time checking (toggled >by an option on the command line, say)? I have in mind run-time >checking of the type provided by Pascal compilers, such as checking >an array subscript against the array bounds, checking a pointer for >reasonable values before dereferencing it. I think that this is very difficult to do in C. Consider a generic "pointer to char" type that can point into any-ol'-char array. What's "reasonable"? There is an alternative, namely to pass the "reasonable" limits to the pointer when it is assigned, but then this requires the char* to be structure: struct char* { val : real char* lo : real char* hi : real char* } and then what do things like: foo = (char *)33; foo = NULL; mean? We can special case them, but now life has gotten a lot more complicated. I won't go into detail, but things do get wierder. ;-D on (Dereferencing an idea) Pardo