【发布时间】:2014-09-05 01:00:28
【问题描述】:
如果启用了优化,则在使用 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.
【问题讨论】:
-
我会说内部编译器错误是一个错误,是的。如果代码无效,您至少会期望出现适当的错误。我相信您的
inc代码没有问题。如果它在没有优化的情况下工作.. -
好像不喜欢healthtype的const。
-
99.99% 的情况下,如果您认为这是编译器错误,那不是。 +1 捕捉真人。
-
内部编译器错误,顾名思义是一个错误
-
@MarkRansom 对于早期的 Delphi 版本,这个数字略低。
标签: delphi