Path: utzoo!attcan!uunet!mcvax!ukc!etive!hwcs!zen!frank From: frank@zen.co.uk (Frank Wales) Newsgroups: comp.lang.c Subject: Re: Survey of "duplicate case in switch" errors Summary: HP-UX seems to get it right on Precision, mostly Message-ID: <1492@zen.UUCP> Date: 25 Jan 89 12:00:03 GMT References: <36376@oliveb.olivetti.com> Reply-To: frank@zen.co.uk (Frank Wales) Organization: Zengrange Limited, Leeds, England Lines: 44 In article <36376@oliveb.olivetti.com> chase@orc.olivetti.com () writes: >For the following file (test.c): >---------------- >foo(i,j,k) int i,j,k; >{ >[...] > case 4: switch (k) > { > case 5: break; > case 5: r = k; /* line 13, for reference */ > case 6: break; > } >[...] >} >---------------- >I get the following diagnostics from four different compilers: >[...] >I am entertained -- error reporting by C compilers is often highly >speculative, but this was extra fun. Anyone care to add to my >collection? HP's contribution to the fray... HP-9000/350SRX, HP-UX 6.2 (pcc-derived, I think) gives: "test.c", line 16: duplicate case in switch, 5 "test.c", line 17: duplicate case in switch, 5 "test.c", line 18: duplicate case in switch, 0 This is identical to SunOS 3.4; interesting, huh? :-) HP-9000/840, HP-UX 2.1 (HP-PA, written entirely by HP): cc: "test.c", line 13: error 1526: Duplicate case constant (5) in switch. which is what I'd expect from the Precision Architecture compilers (this is the C compiler that never says "syntax error"). >(Any vendors out there care to do it right? GCC is >batting .500, including reporting the real live offending line >number.) Ditto HP. Has anyone tried feeding this to lint? On series 800, where the lint is still pcc-derived, you get the wrong triple error message as reported above, just in case you thought you knew what was going on. -- Frank Wales, Systems Manager, [frank@zen.co.uk<->mcvax!zen.co.uk!frank] Zengrange Ltd., Greenfield Rd., Leeds, ENGLAND, LS9 8DB. (+44) 532 489048 x217