Article View: comp.std.c
Article #646Re: Declarations in switches, errors
From: Richard O'Keefe
Date: Sun, 01 Oct 1989 14:32
Date: Sun, 01 Oct 1989 14:32
20 lines
1294 bytes
1294 bytes
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?
Technical Details
Message-ID:
<2260@munnari.oz.au>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!munnari.oz.au!cs.mu.oz.au!okReferences:
<561@crdos1.crd.ge.COM> <11158@smoke.BRL.MIL> <637@crdos1.crd.ge.COM> <19907@mimsy.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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