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,aee8ed05a978aff9,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!news-stoc.telia.net!217.209.241.210.MISMATCH!news-stod.telia.net!telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Persson?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031114 X-Accept-Language: sv, sv-se, sv-fi, en-gb, en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Is this definition legal? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Message-ID: Date: Sat, 18 Sep 2004 23:29:57 GMT NNTP-Posting-Host: 217.209.116.179 X-Complaints-To: abuse@telia.com X-Trace: newsb.telia.net 1095550197 217.209.116.179 (Sun, 19 Sep 2004 01:29:57 CEST) NNTP-Posting-Date: Sun, 19 Sep 2004 01:29:57 CEST Organization: Telia Internet Xref: g2news1.google.com comp.lang.ada:3835 Date: 2004-09-18T23:29:57+00:00 List-Id: GCC-Gnat 3.4.0 is having serious problems with the definition of=20 Character_Encoding below: type Known_OS is (NT, OS2, Linux); This_OS : constant Known_OS :=3D Linux; type Encoding_ID is (UTF_8_ID, ASCII_ID, Latin_1_ID); -- and some others type Unified_Encoding_Record (Known : Boolean; OS : Known_OS) is record= case Known is when True =3D> Which : Encoding_ID; when False =3D> case OS is when Linux =3D> Name : Unbounded_String; when NT | OS2 =3D> Number : Unsigned_16; end case; end case; end record; type Character_Encoding (Known : Boolean :=3D False) is new Unified_Encoding_Record (Known =3D> Known, OS =3D> This_OS); Gnat often crashes with a bug box on a reference to Character_Encoding.=20 For example, when I declare a variable of this type I have to initialize = it at the declaration to avoid a bug box. Also, the predefined "=3D" for = Character_Encoding sometimes returns False for values that should be equa= l. Once when I converted a Character_Encoding to a Unified_Encoding_Record, = the field OS was set to NT, even though This_OS =3D Linux. The next=20 conversion raised Constraint_Error with the message "invalid data". My first question is: Is this definition of Character_Encoding legal and = I should work around the problems until Gnat gets fixed, or is it=20 illegal code that Gnat fails to reject, and I should find another way to = do it? I have also seen an indication that Adjust gets called on the field Name = (Unbounded_String is controlled), even when Known is True, and this is=20 my second question: Should I expect that fields in a variant part are=20 "active" like this even when they are inaccessible because of the=20 discriminant's value? It seems like waste of time to call procedures to=20 maintain a value that can never be read. --=20 Bj=F6rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu