breure%ITIHP1.TNO.NL@pucc.princeton.edu (Frank Breure) (05/16/91)
I discovered a bug in the parser of C68, in a function definition you don't have to use comma's to separate the parameters, thus main(argc argv) /* no comma between argc and argv !! */ int argc; char *argv[]; is accepted! The bug is in decl.c, only if the symbol after an identifier is a comma, the next symbol will be read. The following cdiff will correct this: ----------------- cut here ----------------- *** decl.c Thu May 16 15:22:51 1991 --- decl.c~ Thu May 16 14:22:18 1991 *************** *** 318,325 **** getsym(); if (lastst == comma) getsym(); - else - break; } needpunc(closepa); } --- 318,323 ---- ----------------- cut here ----------------- Frank Breure (breure@itihp1.tno.nl) Instituut voor Toegepaste Informatica-TNO Delft, The Netherlands ---------------------------------------------------------------------- My opinions may be subject to change without notice.
HBO043%DJUKFA11.BITNET@cunyvm.cuny.edu (Christoph van Wuellen) (05/17/91)
Thanks for the report. Errors which only occur with wrong code are difficult to find. C.v.W.
HBO043%DJUKFA11.BITNET@cunyvm.cuny.edu (Christoph van Wuellen) (05/17/91)
I should say that your fix is wrong, too. It would accept declaration
such as
int main(argv,argc,)
the 'real' thing is to move 'needpunc(closepa)' upwards:
if (lastst == comma)
getsym();
else {
needpunc(closepa);
break;
}
C.v.W.
evans@syd.dit.CSIRO.AU (Bruce.Evans) (05/17/91)
In article <53799@nigel.ee.udel.edu> breure%ITIHP1.TNO.NL@pucc.princeton.edu (Frank Breure) writes: > >I discovered a bug in the parser of C68, in a function definition >you don't have to use comma's to separate the parameters, thus > main(argc argv) /* no comma between argc and argv !! */ > int argc; > char *argv[]; >is accepted! It's amusing that the released version of bcc has the same bug. This causes unamusing bugs in conjunction with another bug that allows type declarators in bad places. bcc does not support new-style function definitions, yet it accepts: int foo(int bug) { return bug; } The function is interpreted as having 2 parameters 'int' and 'bug'. 'bug' is given the wrong stack slot (and 'int = 1;' works inside the function :-(). -- Bruce Evans evans@syd.dit.csiro.au