[comp.sources.bugs] Perl 3.0 PL 8 triggers compiler bug

ktl@wag240.caltech.edu (Kian-Tat Lim) (01/05/90)

Description:

	Some compilers may produce incorrect code for the large switch (*s)
in toke.c.  In particular, it is essential that characters with the high
bit set be handled properly.  If this is not the case, failures (most likely
accompanied by core dumps) will be experienced on comp.package, cmd.subval,
io.print, op.dbm, op.index, op.mkdir, op.pack, op.read, op.sort, op.substr,
and op.vec due to mishandling of sort, return, printf, and print followed
by a parenthesized expression.

Repeat-By:

	On an FPS 500 running FPX 4.1.0, make perl and do a 'make test'.
On this system, the compiler generates a jump table for the switch but
fails to properly bounds check the character being switched on.

Fix:

*** toke.c.old	Thu Jan  4 17:57:02 1990
--- toke.c	Thu Jan  4 17:56:36 1990
***************
*** 154,159 ****
--- 154,168 ----
  	else
  	    fprintf(stderr,"Tokener at %s\n",s);
  #endif
+ #ifdef accel
+     if (*s & 128) {
+ 	if ((*s & 127) == '(')
+ 	    *s++ = '(';
+ 	else
+ 	    warn("Unrecognized character \\%03o ignored", *s++);
+ 	goto retry;
+     }
+ #endif
      switch (*s) {
      default:
  	if ((*s & 127) == '(')

--
Kian-Tat Lim (ktl@wagvax.caltech.edu, KTL @ CITCHEM.BITNET, GEnie: K.LIM1)