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, b1, b2);
end.

最佳答案

参见bug report #109124 。我可以在Delphi XE中确认问题;错误报告说它已在 Delphi XE4 中修复。

关于delphi - 此代码是否由于编译器错误而无法构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25677191/

相关文章:

delphi - Delphi 的 XForms 处理器?

delphi - 变量应该在调用函数之前初始化吗?

delphi - 设置 Paintbox 的字体大小会导致调用 OnPaint

delphi - 如何使用 dgRowSelect = False 跟踪选定的行

Delphi 7 tguid 比较

delphi - 编译器如何处理过程/函数内部的过程/函数

delphi - 如何在参数化查询中显式插入空值?

Delphi Graphics32 相对鼠标位置(相对于图层)

Delphi XE4 Indy TBytes 和 TidBytes 之间的兼容性问题

delphi - UDP代理实现