What should a C compiler do?

keashly at mprvaxa.UUCP keashly at mprvaxa.UUCP
Sat Mar 24 08:16:12 AEST 1984


While playing with pcc I stumbled on the following bits
of C that I think are handled incorrectly. The following
code contains two examples:

m(){
int a,b,c;
float d;
   /* case 1 a float switch which the compiler should flag
      as an error (K&R 202) but  pcc (4.1 BSD) doesn't and it
      spits out incorrect code. */
   switch (d) {
      case 4:
	  break;
      case 3:
	  break;
      }

   /* case 2 ideally "a" should have the same value after but pcc
      interprets them differently (K&R say that it is OK 185) */
   if ( a = b++ + b );
   a = b++ + b;
}


All I'm after are comments on the two cases. Myself, I believe 1 is wrong
and 2 disturbing. Thanks.
-- 

    Lance Keashly
    Microtel Pacific Research
    ..decvax!microsoft!ubc-vision!mprvaxa!keashly

    8999 Nelson Way
    Burnaby, B.C., Canada,
    V5A 4B5



More information about the Comp.lang.c mailing list