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,4066f0f220a75baf,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news2.volia.net!news2.dg.net.ua!news.alkar.net!not-for-mail From: Maxim Reznik Newsgroups: comp.lang.ada Subject: Loop parameter type Date: Mon, 25 Sep 2006 10:56:31 +0000 (UTC) Organization: Alkar Teleport News Server Message-ID: <20060925105627.GA14409@ws.max.zp.ua> NNTP-Posting-Host: 213.154.201.133 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pandora.alkar.net 1159181791 16332 213.154.201.133 (25 Sep 2006 10:56:31 GMT) X-Complaints-To: abuse@alkar.net NNTP-Posting-Date: Mon, 25 Sep 2006 10:56:31 +0000 (UTC) Content-Disposition: inline Return-Path: Maxim Reznik User-Agent: Mutt/1.5.11 Xref: g2news2.google.com comp.lang.ada:6718 Date: 2006-09-25T10:56:31+00:00 List-Id: Hi, All Please help me understand Ada name resolution rules for loop parameter specification. Consider follow code: 1: procedure Test is 2: type Int is range 0 .. 1000; 3: C : Integer := 0; 4: C_Int : Int := 0; 5: begin 6: for J in 1 .. 10 loop 7: C := C + J; 8: end loop; 9: 10: for K in 1 .. 10 loop 11: C_Int := C_Int + K; 12: end loop; 13: end Test; gcc -c test.adb test.adb:11:22: invalid operand types for operator "+" test.adb:11:22: left operand has type "Int" defined at line 2 test.adb:11:22: right operand has subtype of "Standard.Integer" defined at line 10 GNAT complains at line 11, but line 7 seems Ok. Why? I expect range 1 .. 10 is root_integer type, because of preference root_integer over others integer types. ARM states: "There is a preference for the primitive operators (and ranges) of the root numeric types root_integer and root_real." In this case both 7 and 11 lines need explicit type conversion. Why GNAT says type of K is Standard.Integer type? Thank you -- Maxim Reznik