[comp.lang.c] cpp bug

hunt@spar.SPAR.SLB.COM (Neil Hunt) (11/19/87)

The following fragment is the boiled down version of some lines
from a C program which was automatically translated from pascal,
and which breaks the cpp on my machine (a Sun 3, 3.2).

% cat test.c
#define l(a)	1

f()
{
	l(
	a); l(
	a)
}
% /lib/cpp test.c
# 1 "test.c" 


f()
{
	 1; # 7 "test.c" 
 1
# 8 "test.c" 
}
%

Of course, the # 7 "test.c" should have been on a line on its own,
not tagged onto the end of the previous line. The compiler complains
about illegal characters and other problems !.

It can be fixed by rearranging almost anything in the test fragment.
The problem seems to be triggered by the occurrence of the start of an
incomplete macro call on the same line as the end of the completion
of another macro call.

I would be very interested to know if anyone else's C cpp exhibits
this problem !

Neil/.

eager@amd.UUCP (11/21/87)

In article <66@spar.SPAR.SLB.COM> hunt@spar.UUCP (Neil Hunt) writes:
>The following fragment is the boiled down version of some lines
>from a C program which was automatically translated from pascal,
>and which breaks the cpp on my machine (a Sun 3, 3.2).
>#define l(a)	1
>
>f()
>{
>	l(
>	a); l(
>	a)
>}




It seems that I remember a restriction in some preprocessors that
requires the entire invocation of a macro to be contained within
a single line.  I looked at Harbison & Steele, but they seem to be
silent on the issue.

-  Mike Eager

gp3147@sdcc15.UUCP (stockfisch) (11/24/87)

In article <4693@amd.AMD.COM>, eager@amd.AMD.COM (mike eager) writes:
> In article <66@spar.SPAR.SLB.COM> hunt@spar.UUCP (Neil Hunt) writes:
> >... breaks the cpp on my machine (a Sun 3, 3.2).
> >#define l(a)	1
> >f()
> >{
> >	l(
> >	a); l(
> >	a)
> >}
> It seems that I remember a restriction in some preprocessors that
> requires the entire invocation of a macro to be contained within
> a single line.  I looked at Harbison & Steele, but they seem to be
> silent on the issue.
> -  Mike Eager



Looking up "macros, calling" in the index of
H&S second edition I am referred to p. 31,
which says (4th line from
bottom)
	
	"Some (deficient) preprocessor implementations
	do not permit
	the actual argument token list to
	extend across multiple
	lines unless the lines to be
	continued end with a \."


|| Tom Stockfisch, UCSD Chemistry tps@sdchemf.ucsd.edu