Survey of "duplicate case in switch" errors

Frank Wales frank at zen.co.uk
Wed Jan 25 22:00:03 AEST 1989


In article <36376 at oliveb.olivetti.com> chase at 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 at zen.co.uk<->mcvax!zen.co.uk!frank]
Zengrange Ltd., Greenfield Rd., Leeds, ENGLAND, LS9 8DB. (+44) 532 489048 x217 



More information about the Comp.lang.c mailing list