[comp.lang.c] Runtime C checks

pardo@uw-june.UUCP (David Keppel) (01/13/88)

I've heard that there is a very good C compiler with runtime debug
capabilites running on the MacIntosh, but I've only heard this once
and wonder whether the source had it confused with Pascal for the Mac.

There is at least one time when array subscripting checks might break legal
C code -- I won't swear to this, but this is how it was told to me:

typedef /* some arbitrary type */ a_type;
typedef struct {
    int		other_stuff;
    a_type	a[1];		/* must be 1, not 0 */
} bork_t;

    bork_t	*x = (bork_t *) malloc(sizeof(bork_t) + (n-1)* sizeof(a_type));

    foo (x->other_stuff, x->a[n-1]);

Allegedly, x is a pointer to a structure containing an int and an array of "n"
a_type things; further (although x->a is defined to be a one-element array)
the reference x->a[n-1] is _purported_ to be _legal_, _portable_ C.

If you have evidence to the contrary, please tell me & I'll post a summary.

    ;-D on  (Ugly?  How about "switch(*x+++++*y){}"?)  Pardo
    pardo@cs.washington.edu   ucbvax!uw-beaver!uw-june!pardo