【问题标题】:Does this code fail to build because of a compiler bug?此代码是否由于编译器错误而无法构建?
【发布时间】: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


【解决方案1】:

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

【讨论】:

  • @SertacAkyuz 它在 Delphi XE 中的“调试”配置中编译,但在“发布”配置中失败,内部错误 C1970。顺便说一句,我通过谷歌搜索“内部错误 C1970”找到了错误报告。
  • @Serge - 这是我的错。删除了我的错误评论和 +1。对不起。
  • 我会假设 C1405 与 C1970 不同,但我们称其为足够接近。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-05-22
  • 2020-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多