From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Subject: Re: Uninitialized variables, Java example
Date: 1996/07/25
Date: 1996-07-25T00:00:00+00:00 [thread overview]
Message-ID: <4t7g2q$ee0@goanna.cs.rmit.edu.au> (raw)
In-Reply-To: Dv1sME.1u4.0.-s@inmet.camb.inmet.com
arra@inmet.com (Arra Avakian) writes:
>Some may view this as extreme, since the compiler can not know statically the
>"truth", and forces a statically knowable work-around on the programmer. Is
>this what some people want for Ada 0x? It seems to me to be a tradeoff between
>efficiency (an unnecessary initialization to satisfy the compiler) and safety
>(the compiler is then allowed to detect statically known cases of
>uninitialized variables, i.e. true programming errors.)
Wrong. If the problem is that the programmer knows that the default:
case can never be executed and the compiler doesn't, then the programmer
should TELL the compiler. For example, in the same situation in C, one
does
int x;
switch (e) {
case ..: ... x = ..; break;
case ..: ... x = ..; break;
default: abort();
}
I actually use a "shouldnt" macro (name stolen with thanks from Interlisp)
which is like assert(0) but cannot be suppressed by NDEBUG.
Now the compiler knows that path can't be traversed too.
Better still, a human reader knows that the original programmmer *thought*
about the problem and didn't just accidentally leave out the default:
And there is no unncessary initialisation anywhere.
In short, this is a perfect example of where a warning about a possibly
uninitialised variable is _really_ a warning about badly written code.
--
Fifty years of programming language research, and we end up with C++ ???
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
next prev parent reply other threads:[~1996-07-25 0:00 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-07-18 0:00 Uninitialized "out" parameters Paul Whittington
1996-07-18 0:00 ` Robert Dewar
1996-07-19 0:00 ` Peter Amey
1996-07-20 0:00 ` Fergus Henderson
1996-07-20 0:00 ` Robert Dewar
1996-07-21 0:00 ` Fergus Henderson
1996-07-21 0:00 ` Robert Dewar
1996-07-23 0:00 ` Fergus Henderson
1996-07-23 0:00 ` Robert A Duff
1996-07-24 0:00 ` Fergus Henderson
1996-07-24 0:00 ` Fergus Henderson
1996-07-23 0:00 ` Richard A. O'Keefe
1996-07-23 0:00 ` Robert Dewar
1996-07-24 0:00 ` Fergus Henderson
1996-07-24 0:00 ` Fergus Henderson
1996-07-24 0:00 ` Robert A Duff
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-25 0:00 ` Robert A Duff
1996-07-23 0:00 ` Robert A Duff
1996-07-24 0:00 ` Richard A. O'Keefe
1996-07-24 0:00 ` Robert A Duff
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-25 0:00 ` Robert A Duff
1996-07-24 0:00 ` Theodore E. Dennison
1996-07-25 0:00 ` Frank Manning
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-26 0:00 ` Frank Manning
1996-07-18 0:00 ` Adam Beneschan
1996-07-18 0:00 ` Robert Dewar
1996-07-19 0:00 ` Dale Stanbrough
1996-07-19 0:00 ` James A. Squire
1996-07-19 0:00 ` Adam Beneschan
1996-07-20 0:00 ` Michael Feldman
1996-07-21 0:00 ` Fergus Henderson
1996-07-21 0:00 ` Michael Feldman
1996-07-21 0:00 ` Robert Dewar
1996-07-22 0:00 ` Fergus Henderson
1996-07-23 0:00 ` Michael Feldman
1996-07-23 0:00 ` Robert Dewar
1996-07-25 0:00 ` Fergus Henderson
1996-07-24 0:00 ` Robert A Duff
1996-07-25 0:00 ` Richard A. O'Keefe
1996-07-24 0:00 ` Fergus Henderson
1996-07-19 0:00 ` Adam Beneschan
1996-07-19 0:00 ` Samuel Tardieu
1996-07-19 0:00 ` John Herro
1996-07-19 0:00 ` Tucker Taft
1996-07-23 0:00 ` Peter Hermann
1996-07-23 0:00 ` Robert A Duff
1996-07-19 0:00 ` Pascal Obry
1996-07-19 0:00 ` Peter Hermann
1996-07-19 0:00 ` Michel Gauthier
1996-07-21 0:00 ` Robert A Duff
1996-07-19 0:00 ` Peter Amey
1996-07-21 0:00 ` Robert A Duff
1996-07-22 0:00 ` Is 'out' different from 'in out' (Was: Uninitialized "out" parameters) Michel Gauthier
1996-07-22 0:00 ` Robert A Duff
1996-07-22 0:00 ` Robert Dewar
1996-07-22 0:00 ` Tucker Taft
1996-07-23 0:00 ` Michel Gauthier
1996-07-23 0:00 ` Robert Dewar
1996-07-24 0:00 ` Pascal Obry
1996-07-25 0:00 ` Tucker Taft
1996-07-23 0:00 ` Uninitialized "out" parameters John Herro
1996-07-23 0:00 ` Robert A Duff
1996-07-24 0:00 ` Uninitialized variables, Java example Arra Avakian
1996-07-25 0:00 ` Richard A. O'Keefe [this message]
1996-07-25 0:00 ` Robert A Duff
1996-07-25 0:00 ` Robert A Duff
1996-07-23 0:00 ` Uninitialized "out" parameters Robert Dewar
1996-07-24 0:00 ` Peter Hermann
1996-07-26 0:00 ` Stephen J Bevan
1996-07-26 0:00 ` Robert A Duff
1996-07-24 0:00 ` Uninitialized variables, Java example Felaco
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox