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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,49ddd117f54c2d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: New to Ada, noticing something strange. References: <1128014442.343461.185800@g49g2000cwa.googlegroups.com> <_xW_e.4596$zQ3.2632@newsread1.news.pas.earthlink.net> <1128020747.226853.325750@z14g2000cwz.googlegroups.com> <1128038313.717692.268490@z14g2000cwz.googlegroups.com> In-Reply-To: <1128038313.717692.268490@z14g2000cwz.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 30 Sep 2005 06:06:31 GMT NNTP-Posting-Host: 67.3.213.152 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1128060391 67.3.213.152 (Thu, 29 Sep 2005 23:06:31 PDT) NNTP-Posting-Date: Thu, 29 Sep 2005 23:06:31 PDT Xref: g2news1.google.com comp.lang.ada:5297 Date: 2005-09-30T06:06:31+00:00 List-Id: mike.martelli@gmail.com wrote: > charMap: array (Character) of Integer; You have undefined elements of this array, and may well be referencing them. You should probably initialize all of them: type Char_Mapping is array (Character) of Integer; Char_Map : Char_Mapping := ('0' => 0, '1' => 1, '2' => 2, ... 'F' => 15, others => -16); > NumOfArgs, size, carry: Integer := 0; By making these Integer, you're implying that negative values are meaningful. These should probably be Natural. Size should probably be Positive. > size := Length(operand1); Why are you using a global variable here? Especially since it doesn't seem to be referenced anywhere else? > when others => return strChar(1); when others => return Strchar (Strchar'First); > --converts all lowercase characters to uppercase Ada.Characters.Handling.To_Upper, as you noted elsewhere. > if charMap(To_String(operand1)(i)) >= charMap(charBase) then Here you can be referencing uninitialized values of Charmap, since the program has no control over the arguments it receives. > for i in reverse 1 .. ResultSize(operand1,operand2) loop > digit := AddDigits(To_String(operand1)(i), To_String(operand2)(i)); One of these strings may be shorter than the result of Resultsize, and when you try to index it with that value (first time through the loop), this should raise Constraint_Error. So, what inputs did you run this with, and what output did you obtain? -- Jeff Carter "There's no messiah here. There's a mess all right, but no messiah." Monty Python's Life of Brian 84