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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeder.erje.net!2.us.feeder.erje.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!newsfeed-00.mathworks.com!panix!not-for-mail From: Dale Dellutri Newsgroups: comp.lang.ada Subject: New to Ada, why these warning messages? Date: Fri, 1 Jan 2016 02:19:41 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: NNTP-Posting-Host: panix1.panix.com X-Trace: reader1.panix.com 1451614781 16294 166.84.1.1 (1 Jan 2016 02:19:41 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 1 Jan 2016 02:19:41 +0000 (UTC) User-Agent: tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (NetBSD/6.1.5 (i386)) Xref: news.eternal-september.org comp.lang.ada:28967 Date: 2016-01-01T02:19:41+00:00 List-Id: I'm trying to compile and run the following program: -- from: http://sandbox.mc.edu/~bennet/ada/examples/arr2_adb.html -- Array aggregates. Array aggregates are essentially constants of -- array type. They can be used either for initialization or in -- assignment statements. -- with Gnat.Io; use Gnat.Io; procedure Gnatarr2 is -- Just some values to play with, along with a conversion array. type Paint is (Red, Green, Yellow, Blue, Pink, Orange, Mauve, Cherry, Indigo, Brown); PNames: array(Paint) of String(1..6) := ("Red ", "Green ", "Yellow", "Blue ", "Pink ", "Orange", "Mauve ", "Cherry", "Indigo", "Brown "); -- The type of an array of paints, along with its size. N: constant := 8; type AType is array(Integer range 1..N) of Paint; -- Some Paint arrays. The first one is initialized with a list -- of colors. A: AType := (Red, Red, Pink, Blue, Orange, Cherry, Indigo, Indigo); B, C: AType; I: Integer; -- Loop index. begin -- Use positions to set varioius values in various places. B := (5 => Green, 2 => Orange, 6..8 => Indigo, 1|3|4 => Brown); -- Set the entire array to Blue. C := (AType'First .. AType'Last => Blue); -- Print the position numbers, spaced out to align with the -- the printouts of each of the arrays below. for I in 1..N loop Put(" "); Put(I); Put(" "); end loop; New_Line; -- Print out the contents of each of A, B, and C. for I in 1..N loop Put(PNames(A(I)) & " "); end loop; New_Line; for I in 1..N loop Put(PNames(B(I)) & " "); end loop; New_Line; for I in 1..N loop Put(PNames(C(I)) & " "); end loop; New_Line; end Gnatarr2; I'm using gcc-gnat on Fedora 22 (I changed the name of the file from arr2.adb to gnatarr2.adb and also the name of the unit to Gnatarr2): $ gnatmake src/gnatarr2.adb -o bin/gnatarr2 gcc -c -Isrc/ -I- src/gnatarr2.adb gnatarr2.adb:24:04: warning: variable "I" is never read and never assigned gnatarr2.adb:54:08: warning: for loop implicitly declares loop variable gnatarr2.adb:54:08: warning: declaration hides "I" declared at line 24 gnatbind -x gnatarr2.ali gnatlink gnatarr2.ali -o bin/gnatarr2 Of course, these are only warnings, and the unit compiles and runs. If I comment out the defintion of I: Integer;, I get: $ gnatmake src/gnatarr2.adb -o bin/gnatarr2 gcc -c -Isrc/ -I- src/gnatarr2.adb gnatbind -x gnatarr2.ali gnatlink gnatarr2.ali -o bin/gnatarr2 In this case, I assume it's using an implicit defintion of I. But I do not understand the warning messages. What's wrong with the definition of I: Integer; on line 24? -- Dale Dellutri (lose the Q's)