Delphi 此代码是否由于编译器错误而无法生成?

Delphi 此代码是否由于编译器错误而无法生成?,delphi,Delphi,如果启用了优化,则在使用Delphi 6时,生成(而不仅仅是编译)以下命令失败,并出现内部编译器错误。使用赋值而不是inc()可以工作。这是一个编译器错误吗?奇怪的记录结构是因为原始代码已经简化为这个最小的示例 program Project1; type requestCountsType = array[0..1] of record processed: int64; end; talliestype = record counts: reque

如果启用了优化,则在使用Delphi 6时,生成(而不仅仅是编译)以下命令失败,并出现内部编译器错误。使用赋值而不是inc()可以工作。这是一个编译器错误吗?奇怪的记录结构是因为原始代码已经简化为这个最小的示例

program Project1;

type
  requestCountsType = array[0..1] of
    record
    processed: int64;
    end;

  talliestype = record
    counts: requestCountsType;
    end;

  healthtype = record
    charged: talliestype;
    end;

procedure computeProcessed(const h: healthtype; var requests, bytesin, bytesout: int64);
var i: byte;
begin
requests := 0; bytesin := 0; bytesout := 0;
for i := 0 to 1 do
  begin
  inc(requests, h.charged.counts[i].processed); // including this generates compiler internal error C1405 when optimization is on
  // requests := requests + h.charged.counts[i].processed; // this works
  end;
end;

var ht: healthtype; var r, b1, b2: int64;

begin
computeProcessed(ht, r, b1, b2);
end.

看。我可以在Delphi XE中确认问题;错误报告说它是在Delphi XE4中修复的。

我认为内部编译器错误是一个错误,是的。如果代码无效,您至少会看到一个正确的错误。我相信你的
inc
代码没有问题。如果它在没有优化的情况下工作..似乎它在99.99%的时间里都不喜欢healthtype的常量,如果你认为这是一个编译器错误,那就不是了+1用于捕捉真实的错误。根据定义,内部编译器错误是bug@MarkRansom对于早期的Delphi版本,这个数字要低一些。@SertacAkyuz它在Delphi XE中以“调试”配置编译,但在“发布”配置中失败,出现内部错误C1970。顺便说一句,我通过谷歌搜索“内部错误C1970”找到了错误报告。@Serge-这是我的错。删除了我的错误评论和+1。对不起,我想C1405和C1970是不一样的,但我们会把它说得很接近。