AV when adding TPair<string,string> to multimap

Issue #163 resolved
Stefan Glienke repo owner created an issue

This code raises an AV

program MultimapAV;

{$APPTYPE CONSOLE}

uses
  Generics.Collections,
  Spring.Collections,
  SysUtils;

procedure Main;
var
  LMap: IMultiMap<string, Generics.Collections.TPair<string, string>>;
  LValue: TPair<string, string>;
begin
  LMap := TCollections.CreateMultiMap<string, TPair<string, string>>();
  LValue := TPair<string, string>.Create('Hallo', 'Welt');
  LMap.Add('Test', LValue);
end;

begin
  try
    Main;
  except
    on E: Exception do
      Writeln(E.Message);
  end;
  Readln;
end.

It seems that the compiler is producing wrong code when passing the TPair to the internal IList in TMultiMapBase<TKey, TValue>.Add where it tries to pass it via stack instead of the address via register.

This can be reproduced on Delphi XE and Berlin

Comments (5)

  1. Log in to comment