C run-time checking

David Keppel pardo at june.cs.washington.edu
Wed Mar 16 09:39:23 AEST 1988


In article <763 at uvm-gen.UUCP> hartley at 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



More information about the Comp.lang.c mailing list