Declarations in switches, errors

Richard O'Keefe ok at cs.mu.oz.au
Mon Oct 2 00:32:00 AEST 1989


In article <19907 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> Even a compiler that is only 1/3 decent% will warn about unreachable
> initialisers.

I tried the following program (laid out to fit in two lines):
	main(argc) int argc; { switch (argc) { int i = 1; double x = 2.0;
        case 1: case 2: exit(i); default: exit(!!x); }}
On a Sun-3/50 running SunOS 4.0.something
	cc:	"line 1: warning: statement not reached"
	CC:	"warning:  statement not reached: case label missing"
	lint:	"(1): warning: statement not reached"
	gcc:	/* silence */
	gcc -W:	/* silence */

I suppose you *could* call this warning about unreachable initialisers,
but calling them unreachable *statements* seems a little unhelpful.
CC's message makes sense because C++ *would* allow a case label before
the declarations (so the initialisers would be done sometimes!).

Do I have permission to call gcc indecent now? 



More information about the Comp.std.c mailing list