how widespread is this cpp bug?

Mark Hall markhall at pyramid.pyramid.com
Thu Dec 1 04:23:49 AEST 1988


The following code compiles and runs on pyramid, att-3b2, and sun3:

	#include <stdio.h>
	main() 
	{
		prin/* comment in the middle */tf ( "Hello World.\n" );
	}

But, according to K&R pg. 179:

	``... comments [...] as described below
	are ignored except as they serve to separate tokens.''

So the above program is actually in error, as `prin' and `tf' should
be two separate tokens.  I was going to fix our cpp until I realized 
how pervasive the bug is.   Looking into the June draft of the standard
I see that they have addressed this problem explicitly, and mention that
all comments are to be replaced with a single space.  I hear that
this `feature' is used for gluing togehter tokens, as in:

#define VERSION 2
main() {
	proc/**/VERSION( a,b,c );
}

which, given the buggy cpp, will produce:

main() {
	proc2( a,b,c );
}

Does your cpp have this `feature'?  Anyone know the history?  I
suspect that AT&T and SUN know about this, but have chosen not to fix it.
Anyone know why?

-Mark Hall (smart mailer): markhall at pyramid.pyramid.com
	   (uucp paths): {ames|decwrl|sun|seismo}!pyramid!markhall



More information about the Comp.lang.c mailing list