type punning

cottrell at nbs-vms.ARPA cottrell at nbs-vms.ARPA
Tue Feb 12 10:30:49 AEST 1985


/*
> > Note the lack of cast on h in Put_Tail.
> 
> Oh, JHFC, Gary, RTFM.  K&R says that the coercion of 0 to a null pointer
> of the appropriate type is automatic in what amount to all situations where
> the compiler can figure this out.  Stop talking about the lack of casts
> in statements like "if (!h)"; they never were required and never will be.

Gotcha this time Guy! The omitted cast was in the funxion call to `insque'.
Part of my message follows:

~ LINKP remque(LINKP p);		/* remove p from list */
~ {	if (p)	(p->fwd->bwd = p->bwd)->fwd = p->fwd;
~ 	return(p);
~ }
~ 
~ LINKP insque(LINKP p,LINKP q);	/* insert p after q */
~ {	if (p)	(((p->fwd = q->fwd)->bwd = p)->bwd = q)->fwd = p;
~ 	return(p);
~ }
~ 
~ LINKP Put_Head(HEADP h,LINKP p);	/* put p to head of list h */
~ {	if (!h) return(0);		/* null protect */
~ 	++h->cnt;			/* one more */
~ 	return(insque(h->link.fwd,p);	/* put to head */
~ }
~ 
~ LINKP Put_Tail(HEADP h,LINKP p);	/* put p to tail of list h */
~ {	if (!h) return(0);		/* null protect */
~ 	++h->cnt;			/* one more */
~ 	return(insque(h,p);		/* put to tail */
~ }
~ 
~ Note the lack of cast on h in Put_Tail. 

Admittedly this required you to muddle thru a lot of possibly boring
code, but, he who lives by the nit dies by the pick.

I have an idea what JHFC means, but what does RTFM mean? BTW, my name
is not Gary, it's Jim. Okay, I figured it out. Better watch out, Guy,
there is a pea-brain at Princeton who doesn't like "obscenity", even
when it's encoded in asterisks. He sent a nastygram to our postmaster
about my u-wiz message about `vm on a 680x0'. You know, the one that said:

	What the      is this      doing in unix-wizards?
	Hey, just kidding guys :-)
*/



More information about the Comp.lang.c mailing list