Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 May 1997 02:50:01 -0700 (PDT)
From:      j@uriah.heep.sax.de (J Wunsch)
To:        freebsd-bugs
Subject:   Re: gnu/3554: cc failed on deafult <= default
Message-ID:  <199705090950.CAA24080@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR gnu/3554; it has been noted by GNATS.

From: j@uriah.heep.sax.de (J Wunsch)
To: jin@iss-p1.lbl.gov
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: gnu/3554: cc failed on deafult <= default
Date: Fri, 9 May 1997 10:44:31 +0200

 As Jin Guojun[ITG] wrote:
 
 > >Description:
 > 
 > 	switch (x) {
 > 	case ...
 > 	...
 > 	deafult: ...	/* no error reported, but fails	*/
 > 	}
 
 This is legal C code.  deafult: is just a label as any other case
 labels, or a plain label as in:
 
 	for (i = 0; i < max; i++) {
 		someptr = &array[i];
    defualt:
    do_again:
 
 		...
 		if (some_condition) {
 			goto do_again;	/* both statements are the same */
 			goto defualt;
 		}
 		...
 	}
 
 You should get a warning about an unused label with -Wall.
 
 Or to quote some more twisted example here, take Duff's device:
 
 :Duff's device: n. The most dramatic use yet seen of {fall
    through} in C, invented by Tom Duff when he was at Lucasfilm.
    Trying to {bum} all the instructions he could out of an inner
    loop that copied data serially onto an output port, he decided to
    {unroll} it.  He then realized that the unrolled version could
    be implemented by *interlacing* the structures of a switch and
    a loop:
 
         register n = (count + 7) / 8;       /* count > 0 assumed */
 
         switch (count % 8)
         {
         case 0: do {    *to = *from++;
         case 7:         *to = *from++;
         case 6:         *to = *from++;
         case 5:         *to = *from++;
         case 4:         *to = *from++;
         case 3:         *to = *from++;
         case 2:         *to = *from++;
         case 1:         *to = *from++;
              } while (--n > 0);
         }
 
    Having verified that the device is valid portable C, Duff announced
    it.  C's default {fall through} in case statements has long been
    its most controversial single feature; Duff observed that "This
    code forms some sort of argument in that debate, but I'm not sure
    whether it's for or against."
 
 (Courtesy the Jargon file, of course.)
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
 Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705090950.CAA24080>