Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!polyslo!ttwang From: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Newsgroups: comp.arch Subject: Re: Parity hardware for uninitialized variable checking? Message-ID: <14166@polyslo.CalPoly.EDU> Date: 1 Sep 89 22:13:08 GMT References: <12.filbo@gorn.santa-cruz.ca.us> <4322@druhi.ATT.COM> Reply-To: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Distribution: usa Organization: Cal Poly State University -- San Luis Obispo Lines: 40 terrell@druhi.ATT.COM (TerrellE) writes: >One of the machines that Cray designed for CDC had 1's complement (not 2's >complement) arithmetic. 1's complement has two representations for 0 >(positive and negative). >Cray took advantage of this and made one of the 0 representations a designated >undefined value. The hardware would trap on an attempt to read a variable with >this undefined value. >I really wish that micros could be coerced to do this kind of checking! I'd >even like my compiler to generate extra code to check for undefined variable >references (not too difficult to do - but would make the object code larger). >No check for undefined variable access leaves a gaping hole in the security >mechanisms of Pascal, Modula 2, etc. While these languages will check for >out of range variable values, out of bounds array references, you're out of >luck with undefined variables. The problems you mentioned are the problem of the particular languages. The hardware should not be be doing error detection which the software should be handling in the first place. The fact that you can use a variable before initializing it shows the flaw in the language design. Every variables should be initialized. The C++ language is a modern language which you can have a high confidence that all variables are initialized. If you take the object-oriented view, allowing the creation of an object with undefined initial state is an obvious error. >There is probably a much simpler scheme... Yes. Insist you initialize a variable when you create it. >Terrell (att!druhi!terrell) -Thomas Wang (Ah so desu ka!) ttwang@polyslo.calpoly.edu