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,6cbbf1799c1dc6da X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newspeer2.se.telia.net!se.telia.net!masternews.telia.net.!newsc.telia.net.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Persson?= User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada 2005 box (<>) rules in default values References: <43CCAB76.6050907@mailinator.com> In-Reply-To: <43CCAB76.6050907@mailinator.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Date: Tue, 17 Jan 2006 21:15:31 GMT NNTP-Posting-Host: 83.250.94.67 X-Complaints-To: abuse@telia.com X-Trace: newsc.telia.net 1137532531 83.250.94.67 (Tue, 17 Jan 2006 22:15:31 CET) NNTP-Posting-Date: Tue, 17 Jan 2006 22:15:31 CET Organization: Telia Internet Xref: g2news1.google.com comp.lang.ada:2517 Date: 2006-01-17T21:15:31+00:00 List-Id: Alex R. Mosteo wrote: > My understanding is that you use the <> value to denote the default > value of a field in, for example a (limited or not) record: > > Blah : constant Thing := > (First_Component => 3, > Second_Component => 4, > others => <>); > > This actually compiles in GNAT GAP/GPL, but there's a thing happening > that I don't know if it's that it isn't still completely implemented in > Gnat, or is the expected behavior. > > Say, for example, that Thing above is declared like: > > type Thing is record > First_Component : Integer; > Second_Component : Integer; > Third_Component : Integer := 5; > end record; > > I'm finding that if I use the box as in the first example above, the > third component will not receive its default value from the type > definition (5), but will be uninitialized. This appears to be corrected in GCC 4.0.2 on Gnu/Linux, as it passes the test below. Alex, could you please compile this program and verify that it triggers the bug in your environment? If not, you might want to post a compilable test case that does display the error. with Ada.Text_IO; use Ada.Text_IO; procedure Uninitialized_Field_2005 is type Thing is record First_Component : Integer; Second_Component : Integer; Third_Component : Integer := 5; end record; Blah : constant Thing := (First_Component => 3, Second_Component => 4, others => <>); begin if Blah.Third_Component = 5 then Put("Passed"); else Put("Failed"); end if; Put_Line(": Blah.Third_Component = " & Integer'Image(Blah.Third_Component)); end Uninitialized_Field_2005; $ gnatmake -gnat05 uninitialized_field_2005.adb gcc -c -gnat05 uninitialized_field_2005.adb gnatbind -x uninitialized_field_2005.ali gnatlink uninitialized_field_2005.ali $ ./uninitialized_field_2005 Passed: Blah.Third_Component = 5 -- Bj�rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu