From owner-freebsd-hackers Wed May 21 13:44:47 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id NAA04994 for hackers-outgoing; Wed, 21 May 1997 13:44:47 -0700 (PDT) Received: from mail1.its.rpi.edu (root@mail1.its.rpi.edu [128.113.100.7]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id NAA04988 for ; Wed, 21 May 1997 13:44:43 -0700 (PDT) Received: from mlor.its.rpi.edu (mlor.its.rpi.edu [128.113.24.92]) by mail1.its.rpi.edu (8.8.5/8.8.5) with SMTP id QAA163040; Wed, 21 May 1997 16:44:31 -0400 Received: by mlor.its.rpi.edu (NX5.67f2/NX3.0M) id AA07750; Wed, 21 May 97 16:47:14 -0400 Message-Id: <9705212047.AA07750@mlor.its.rpi.edu> Mime-Version: 1.0 (NeXT Mail 3.3 v118.2) Content-Type: text/plain; charset=us-ascii Received: by NeXT.Mailer (1.118.2) From: Garance A Drosehn Date: Wed, 21 May 97 16:47:13 -0400 To: Terry Lambert Subject: Re: Variable initialization Cc: hackers@FreeBSD.ORG Reply-To: gad@eclipse.its.rpi.edu References: <199705191630.JAA24310@phaeton.artisoft.com> Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.freebsd.org id NAA04989 Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > A wrongly initialized variable is worse than an initialized > > one since it can't be checked for. > > Won't an incorrect initialization become obvious when the code > fails to function? Not necessarily. In the days when mainframes ruled the earth, here at RPI we ran an operating system called MTS. One difference between MTS and standard IBM operating systems was that IBM generally initialized storage to zero, while we initialized it to X'81818181'. Compilers weren't smart enough to warn about variables which were not explicitly initialized at compile time. So, if you did not initialize your variables, you'd get different results under MTS than under some other operating systems. In some of those cases, the uninitialized variables really were expected to be zero, and the programmer just never initialized it. In other cases, however, the initial value was *not* supposed to be zero, but since the program had worked no one realized the answers were wrong. In a few cases we had people who refused to believe that their code was wrong (even if we explicitly showed them the problem), because they had already built things based on the incorrect results they had gotten by running the program on other systems, and they simply did not want to believe that all their work had been completely misguided. There is a significant difference between "fails to function" and "functions perfectly fine with absolutely no errors, but just happens to give you the wrong answers"... --- Garance Alistair Drosehn = gad@eclipse.its.rpi.edu Senior Systems Programmer (MIME & NeXTmail capable) Rensselaer Polytechnic Institute; Troy NY USA