another pcc bug

utzoo!decvax!duke!mcnc!unc!tim utzoo!decvax!duke!mcnc!unc!tim
Mon Mar 28 15:24:00 AEST 1983


The portable C compiler tries to be too smart for its own good
in lexical analysis. Consider the following fragment:

int i, *ptr;
ptr = &i;		/* ptr is set to address of i */
ptr=&i;			/* same as above */

The second statement is lexically identical to the first; however,
PCC decides that it should be parsed as:

ptr =& i ;

Of course, the =& operator is from earlier versions of C, and is no
longer valid, so PCC gives an error message and assumes that what you
meant to say was "ptr &= i ;" which is a type mismatch, as well as
being different from the real meaning.

The token "=&" became invalid. Instead of being removed from the lexical
analyzer, it was left in as an "error condition". This is immensely stupid;
the whole reason for getting rid of it was to remove the ambiguity that
is still causing the problem.

Tim Maroney



More information about the Comp.lang.c mailing list