[net.unix-wizards] In defense of C

dan@rna.UUCP (02/27/84)

Hi,
	When debugging programs compiled by C compilers which subroutine
returns branch to a single machine language return instruction, you can
then always catch the C function as it is returning with a single breakpoint.
This is a "feature" that I often use in debugging C subroutines.
	Also, "over"-optimization of C in the kernel and similar real-time and
interrupt handling situations can really mess you up - probably the fault of
C's definition (or lack of appropriate constructs).

						Cheers,
						Dan Ts'o
						...cmcl2!rna!dan

grt@hocda.UUCP (G.TOMASEVICH) (02/28/84)

The comments concerning non-automatic reuse of automatic variables with
nonoverlapping domains reminded me that one can reuse register variables.
I don't know if this applies to non-register automatics and would be
interested in finding out.  One can create blocks, as in ALGOL, with curly
braces, in which registers are re-used, according to what I have seen in
PDP assembly translation of C.  Example:

func(a)
{
	register int i, j;
	switch(a) {
	case 0:
	    {
	    register int x;
	    ...
	    break;
	    }
	case 1:
	    {
	    register int y;
	    ...
	    break;
	    }
	}
}

The variables 'x' and 'y' are assigned to the same register.  How much
of this ALGOL type blocking exists in C?  Can someone point me to any
references?  (How big is a pointer to a document? :-) )

phil@unisoft.UUCP (03/06/84)

>> The comments concerning non-automatic reuse of automatic variables with
>> nonoverlapping domains reminded me that one can reuse register variables.
>> I don't know if this applies to non-register automatics and would be
>> interested in finding out.  One can create blocks, as in ALGOL, with curly
>> braces, in which registers are re-used, according to what I have seen in
>> PDP assembly translation of C .......

Well, I wouldn't count on it. Remember that register storage class is more
of an advisory, any C compiler is free to ignore it at any time. Some
C compilers will allocate ALL the auto storage class at once upon entering
the function. The VAX 4.1 BSD C compiler (as far as I can see) allocates
all the required auto storage class upon entry.