comp.lang.ada
 help / color / mirror / Atom feed
From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: Default comparison of tagged variant records
Date: 8 Dec 2006 10:30:31 -0800
Date: 2006-12-08T10:30:31-08:00	[thread overview]
Message-ID: <1165602630.553040.134960@n67g2000cwd.googlegroups.com> (raw)
In-Reply-To: 1165585768.342140.201110@16g2000cwy.googlegroups.com

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




  reply	other threads:[~2006-12-08 18:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-08 13:49 Default comparison of tagged variant records msimonides
2006-12-08 18:30 ` Adam Beneschan [this message]
2006-12-09  1:38   ` Randy Brukardt
2006-12-11  7:40     ` msimonides
2006-12-11 23:12       ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox