Dubious C code

Alan Myrvold alanm at cognos.uucp
Sat Feb 11 04:50:11 AEST 1989


In article <9619 at smoke.BRL.MIL> gwyn at brl.arpa 
   (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <1508 at zen.UUCP> frank at zen.co.uk (Frank Wales) writes:
>>The question is, *should* it compile without any complaints at all?
>
>Why not?  It's legitimate C code.  It follows the rules.
>So what if it's a stupid algorithm?  It's not the compiler's
>job to criticize the choice of algorithms.

I didn't realize that a CASE statement within the body of a FOR loop
was legitimate C code, and just a stupid algorithm.

Curiously enough, although it compiles without complaints and generates
the same output on UNIX cc, UNIX gcc, PC-DOS Turbo C, IBM MVS/TSO SAS C,
and IBM MVS/TSO IBM C (109 Bananas) ... 

VAX/VMS cc does have the sense to complain :

$ cc rainbow.c

	    case 1:
%CC-E-NOTSWITCH, Default labels and case labels are
		valid only in "switch" statements.
		At line number 17 in PATH$USR:[USR.ALANM]RAINBOW.C;1.

	}
%CC-I-NOBJECT, No object file produced.
		At line number 25 in PATH$USR:[USR.ALANM]RAINBOW.C;1.

%CC-I-SUMMARY, Completed with 1 error(s), 0 warning(s), and
		1 informational messages.
		At line number 26 in PATH$USR:[USR.ALANM]RAINBOW.C;1.

%CC-I-NOBJECT, No object file produced.
		At line number 26 in PATH$USR:[USR.ALANM]RAINBOW.C;1.


$
---
Alan Myrvold          3755 Riverside Dr.     uunet!mitel!sce!cognos!alanm
Cognos Incorporated   P.O. Box 9707          alanm at cognos.uucp
(613) 738-1440 x5530  Ottawa, Ontario       
                      CANADA  K1G 3Z4       



More information about the Comp.lang.c mailing list