Path: utzoo!attcan!uunet!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.std.c Subject: Re: Declarations in switches, errors Message-ID: <2260@munnari.oz.au> Date: 1 Oct 89 14:32:00 GMT References: <561@crdos1.crd.ge.COM> <11158@smoke.BRL.MIL> <637@crdos1.crd.ge.COM> <19907@mimsy.UUCP> Sender: news@cs.mu.oz.au Lines: 20 In article <19907@mimsy.UUCP>, chris@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?