如果打开优化,使用 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.
最佳答案
参见bug report #109124 。我可以在Delphi XE中确认问题;错误报告说它已在 Delphi XE4 中修复。
关于delphi - 此代码是否由于编译器错误而无法构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25677191/