Path: utzoo!dciem!nrcaer!sce!cognos!alanm From: alanm@cognos.uucp (Alan Myrvold) Newsgroups: comp.lang.c Subject: Re: Dubious C code Message-ID: <5251@cognos.UUCP> Date: 10 Feb 89 18:50:11 GMT Article-I.D.: cognos.5251 References: <1508@zen.UUCP> <9619@smoke.BRL.MIL> Reply-To: alanm@cognos.UUCP (Alan Myrvold) Organization: Cognos Inc., Ottawa, Canada Lines: 43 In article <9619@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <1508@zen.UUCP> frank@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@cognos.uucp (613) 738-1440 x5530 Ottawa, Ontario CANADA K1G 3Z4