Infinite loop when trying to set TDictionary.MaxLoadFactor

Summary

An attempt to set MaxLoadFactor for an empty TDictionary instance leads to an infinite loop.

System Information

  • Operating system: Linux, Windows
  • Processor architecture: x86-64
  • Compiler version: 3.2.2, 3.3.1-14572-g3a5cd076-dirty

Example Project

program test;
{$mode delphi}
uses
  SysUtils, Generics.Collections;
var
  MyMap: TDictionary<string, Integer>;
begin
  MyMap := TDictionary<string, Integer>.Create;
  MyMap.MaxLoadFactor := 0.6; // <-- stuck here forever
  WriteLn('done!');
  MyMap.Free;
end.

Possible fixes

The attached patch seems to solve the problem.

dict.patch

Edited by avk959