comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: bug or feature
Date: Mon, 08 Sep 2014 10:43:39 +0100
Date: 2014-09-08T10:43:39+01:00	[thread overview]
Message-ID: <lyk35eih10.fsf@pushface.org> (raw)
In-Reply-To: 136dc796-8f60-4fc0-a2f8-70e0ca24c9f1@googlegroups.com

Charly <carl.weierstrass@googlemail.com> writes:

> I found the following strange behavior of gnat-gpl-2014 (ubuntu linux
> amd64) and I wonder, if it is a bug in gnat:
>
> I habe a package Datum_Pkg that defines a tagged type Datum and
> Datum_Vector (using Ada.Conainers.Vectors). In the main program I want
> to iterate over the vector (all irrelevant lines removed):
[...]

> Line 13 compiles without message but in line 17 I get an error message:
>    subtype indication does not match element type
> But this line should be equivalent to line 13 because of the subtype
> definition in line 6.

Looks like a regression.

I tried this compilable version of your code

with Ada.Containers.Vectors;
with Ada.Text_IO;
procedure Datum is

   package Datum_Pkg is
      type Datum is tagged record
         V : Integer;
      end record;
      function Image (This : Datum) return String is (This.V'Img);
      package Datum_Vectors
        is new Ada.Containers.Vectors (Index_Type   => Positive,
                                       Element_Type => Datum);
      type Datum_Array is array (Positive range 1 .. 10) of Datum;
   end Datum_Pkg;

   subtype Datum is Datum_Pkg.Datum;
   subtype Datum_Vector is Datum_Pkg.Datum_Vectors.Vector;
--   subtype Datum_Vector is Datum_Pkg.Datum_Array;

   D_Vec : Datum_Vector;

begin

   for Dat : Datum_Pkg.Datum of D_Vec loop
      Ada.Text_IO.Put_Line ("Datum=" & Dat.Image);
   end loop;

   for Dat : Datum of D_Vec loop
      Ada.Text_IO.Put_Line ("Datum=" & Dat.Image);
   end loop;

end Datum;

and it fails as you say with GNAT GPL 2014 and FSF GCC 4.9.0. However,
GNAT GPL 2013 and FSF GCC 4.8.1 are both happy.

Not that that would mean it's a regression, necessarily, but if you swap
the definition of subtype Datum_Vector to the array version compilation
succeeds.


  parent reply	other threads:[~2014-09-08  9:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-07 10:33 bug or feature Charly
2014-09-07 16:59 ` Dirk Heinrichs
2014-09-08  8:48   ` Stephen Leake
2014-09-08 18:07     ` Charly
2014-09-09  4:32       ` Stephen Leake
2014-09-09  4:39     ` Dirk Heinrichs
2014-09-08  8:51 ` Stephen Leake
2014-09-08  9:09   ` J-P. Rosen
2014-09-08 15:31   ` Adam Beneschan
2014-09-08  9:43 ` Simon Wright [this message]
2014-09-09  4:40   ` Stephen Leake
2014-10-06 17:48     ` Simon Wright
replies disabled

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