【问题标题】:Ada.Containers.Vectors not working with GNAT GPL 2017Ada.Containers.Vectors 不适用于 GNAT GPL 2017
【发布时间】:2017-09-27 19:03:34
【问题描述】:

我正在尝试编译这段代码:

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 给出这个输出:

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

错误信息导致 stdlib 的实现中的这个过程:

   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;

看起来不错。我不明白错误消息,这里有什么问题?它是标准库中的错误吗?

【问题讨论】:

  • gnat --version 没问题 > GNAT GPL 2017 (20170515-63)。
  • 相反,我看到了New_Item : Element_Type; -- Default-initialized value
  • 这里的 GNAT GPL 2017 也没有问题。 (在 Debian/Jessie 上。)
  • 我在 GCC 4.9.1、5.2.0、6.1.0、7.1.0、8.0.0、GNAT GPL 2015、2016、2017(在 macOS 上)中没有看到这一点。
  • @trashgod:像这样更改该行有效。看起来这个文件被篡改了,虽然我不能说这是怎么发生的。

标签: ada gnat


【解决方案1】:

这个文件好像被篡改了……

总结证据,

  • 多个comments 报告 GNAT 版本可以追溯到 4.9.1。

  • 标记为&lt;&lt; here 的初始化是一个编译时错误,因为compound delimiter &lt;&gt;,名为,在expression 中使用的@987654324 中无效@。

  • 基于How gnatmake Worksa-convec.adb只有在修改对应的.ali文件后才会重新编译。

未来,你可能会

  • 检查a-convec.adba-convec.ali的修改日期,分别在adaincludeadalib目录中。

  • 重新安装编译器。

  • 必要时通知上游维护者。

【讨论】:

  • New_Item : Element_Type; 代码可追溯到 2005 年 11 月 15 日!并且仍然存在于最新的 GCC 源中。
  • @SimonWright:我注意到GNAT GPL 2015 来源日期为 2015 年 5 月 6 日的同一件事。
猜你喜欢
  • 2023-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-25
  • 1970-01-01
  • 1970-01-01
  • 2019-06-12
  • 1970-01-01
相关资源
最近更新 更多