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,96eed9f3fe0e5887 X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: Yet another gnat/TFFE difference Date: 1999/05/22 Message-ID: #1/1 X-Deja-AN: 480834139 References: <7i4vjh$n4t$1@nnrp1.deja.com> X-Complaints-To: usenet@nusku.cts.com X-Trace: nusku.cts.com 927365774 6860 198.68.168.21 (22 May 1999 09:36:14 GMT) Organization: CTS Network Services NNTP-Posting-Date: 22 May 1999 09:36:14 GMT Newsgroups: comp.lang.ada Date: 1999-05-22T09:36:14+00:00 List-Id: dennison@telepath.com writes: > I have found one last difference between Gnat and Tucker's favorite > front end (both Aonix and GreenHills variants). This one has to do with > array slicing and type conversions. Assume I have the following code: > > > type T1 is array (1..2250) of Float; > O1 : T1; > > type T2 is array (1..5) of Float; > O2 : T2: > > ... > > O2(1..2) := T2 (O1 (2..3)); > > > Gnat has no problem with this, which makes sense as the slices are the > same size and the base type of the arrays are the same. I think you mean element type, not base type. > TFFE compilers blow up with a constrataint error here. I'm gessing that > is because objects of type T2 have to be 5 elements long, but my slice > is 2 elements. A conversion to subtype T2 includes a constraint check against T2's bounds, 1..5, so the Constraint_Error is correct. > I have two questions here: First off, which vendor gets the bug > report? :-) Probably neither one. I just tried this with GNAT 3.11p, and it did raise Constraint_Error. > Secondly, does anyone have any good ideas about how to make the TFFE > compilers happy? It doesn't make sense that I should have to make two > separate assignments to do this. I know making T1 a subtype of T2 would > work. But in the environment this came up in that is not a feasable > solution (T2 is actually sized based on generic-derived parameters that > are only known at runtime). You're doing an array subtype conversion; what you want is an array base type conversion. The problem is, the base types are anonymous. Here's something that should do what you want: type UT1 is array(Positive range <>) of Float; subtype T1 is UT1(1..2250); O1 : T1; type UT2 is array(Positive range <>) of Float; subtype T2 is UT2(1..5); O2 : T2; ... O2(1..2) := UT2 (O1 (2..3)); (I'm probably misusing the terms "subtype" and "base type".) -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> Techno-geek. Mouse bigger than phone. Bites heads off virtual chickens.