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,e408bb0b4469b67c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!n67g2000cwd.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Default comparison of tagged variant records Date: 8 Dec 2006 10:30:31 -0800 Organization: http://groups.google.com Message-ID: <1165602630.553040.134960@n67g2000cwd.googlegroups.com> References: <1165585768.342140.201110@16g2000cwy.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1165602637 6079 127.0.0.1 (8 Dec 2006 18:30:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 8 Dec 2006 18:30:37 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: n67g2000cwd.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news2.google.com comp.lang.ada:7867 Date: 2006-12-08T10:30:31-08:00 List-Id: msimonides@power.com.pl wrote: > I'm having problem with default comparison of tagged, variant records > not calling user-defined "=" operators for record components. At least > that's, what I think. > > Here is an example: > > with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; > with Ada.Text_IO; use Ada.Text_IO; > > procedure Test is > > type Thing is tagged > record > null; > end record; > > type Bigger_Thing (Discriminant : Boolean) is new Thing with > record > case Discriminant is > when True => > Text : Unbounded_String; > when False => > Number : Natural; > end case; > end record; > > Big_Something : constant Bigger_Thing := Bigger_Thing'( > Discriminant => True, Text => Null_Unbounded_String); > Big_Something_Copy : constant Bigger_Thing := Big_Something; > > begin > Put_Line ("Are they equal?"); > Put_Line (Boolean'Image (Big_Something = Big_Something_Copy)); > end Test; > > > It prints "FALSE" and does it for both values of Discriminant, so even > when Text component isn't used. > However, comparison works properly when either there is no > Unbounded_String, the record isn't tagged or the record doesn't have a > discriminant. This looks like a compiler bug to me. It should return TRUE in those all cases. -- Adam