flyx
flyx

Reputation: 39668

Ada.Containers.Vectors not working with GNAT GPL 2017

I am trying to compile this code:

with Ada.Containers.Vectors;

procedure Test is
   type My_Type is range -1 .. Integer'Last;
   package My_Vectors is new Ada.Containers.Vectors (Positive, My_Type);
   Vector : My_Vectors.Vector;
begin
   Vector.Append (-1);
end Test;

gnatmake test.adb gives this output:

gcc -c test.adb
a-convec.adb:1553:33: missing operand
gnatmake: "test.adb" compilation error

The error message leads to this procedure in the stdlib's implementation:

   procedure Insert
     (Container : in out Vector;
      Before    : Extended_Index;
      Count     : Count_Type := 1)
   is
      New_Item : Element_Type := <>;  --  << here
      pragma Warnings (Off, New_Item);

   begin
      Insert (Container, Before, New_Item, Count);
   end Insert;

It looks fine. I don't understand the error message, what's wrong here? Is it a bug in the stdlib?

Upvotes: 1

Views: 296

Answers (1)

trashgod
trashgod

Reputation: 205785

Looks like this file has been tampered with…

Summarizing the evidence,

  • Multiple comments report no problem with GNAT versions going back as far as 4.9.1.

  • The initialization marked << here is a compile-time error, as the compound delimiter <>, named box, is not valid in an expression used in assignment.

  • Based on How gnatmake Works, a-convec.adb would only be recompiled if it were modified after the corresponding .ali file.

Going forward, you might

  • Check the modification dates of a-convec.adb and a-convec.ali, found in the adainclude and adalib directories, respectively.

  • Reinstall the compiler.

  • Notify upstream maintainers if warranted.

Upvotes: 2

Related Questions