From: Maxim Reznik <reznikmm@front.ru>
Subject: Loop parameter type
Date: Mon, 25 Sep 2006 10:56:31 +0000 (UTC)
Date: 2006-09-25T10:56:31+00:00 [thread overview]
Message-ID: <20060925105627.GA14409@ws.max.zp.ua> (raw)
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
next reply other threads:[~2006-09-25 10:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-25 10:56 Maxim Reznik [this message]
2006-09-25 11:50 ` Loop parameter type Stuart
2006-09-25 16:32 ` Robert A Duff
2006-09-25 19:08 ` Jeffrey R. Carter
2006-09-26 0:12 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox