From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,803df5f3f60558d5 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Uninitialized "out" parameters Date: 1996/07/18 Message-ID: #1/1 X-Deja-AN: 168943703 references: <31EEACDA.64880EEB@sage.inel.gov> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-07-18T00:00:00+00:00 List-Id: Paul asked "In the following Ada program, should either the compiler or the run-time get some kind of error because the out parameter is not initialized? procedure Testit is procedure SubP (op : out Integer) is begin op := op+1; end SubP; I : Integer; begin SubP (I); end Testit; The answer is that this program is perfectly legal, so it would be incorrect for a compiler to reject it. At execution time, if subp is called, then the addition operation references an uninitialized variable and renders the program execution erroneous, which means anything might happen, but you certainly cannot expect/require a runtime error. The execution might raise Program_Error, but it also might do anything else. A compiler could give a warning for this program. For example, GNAT, using the option -Wuninitialized (warn on uninitialized variable use), gives testit.adb: In function `subp': testit.adb:3: warning: `op' might be used uninitialized in this function But certainly it is impossible for a compiler to give warnings in all cases of uninitialized variable use.