【发布时间】: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:像这样更改该行有效。看起来这个文件被篡改了,虽然我不能说这是怎么发生的。