delphi – 由于编译器错误,此代码是否无法构建?

前端之家收集整理的这篇文章主要介绍了delphi – 由于编译器错误,此代码是否无法构建?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
构建,而不仅仅是编译,如果使用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,b2);
end.

解决方法

bug report #109124.我可以在Delphi XE中确认问题;该bug报告说在Delphi XE4中已经修复了.

猜你在找的Delphi相关文章