Compiler backend error on iOS when creating a Dictionary with a non-reference type as value

Issue #264 wontfix
Jens Mertelmeyer created an issue

The build process fails on iOS 64 (Debug and Release) with cryptic "backend error" messages for calling

Spring.Collections.TCollections.CreateDictionary<X, Y>();

where Y has to be a value type like TDateTime, Integer or TSomeRecord.

Examples for a compiler error message:

[DCC Fehler] Unit1.pas(40): E2581 Backend-Fehler: Incorrect number of arguments passed to called function! %13 = tail call fastcc i128 %11(i8 %5, %1680 %12, %1682* %2), !dbg !26082

Example code to reproduce

  1. Use Delphi 10.1 Berlin with Update 2
  2. Create a Multi-platform-application
  3. Compile for iOS 64 Bit
  4. Try the following code
unit Unit1;

interface uses
  System.SysUtils, System.Classes,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs
;

type
  TSomeEnum = (uno, dos, tres);

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation uses Spring.Collections;

{$R *.fmx}

procedure TForm1.FormCreate(Sender: TObject);
const
  capacity = 10;
begin
  {.$Define FAIL}

  {$If Defined(FAIL)}
    TCollections.CreateDictionary<Integer, TDateTime>(capacity);
    TCollections.CreateDictionary<Integer, TSomeEnum>(capacity);
  {$EndIf}

  // no problem with this one
  TCollections.CreateDictionary<Integer, String>(capacity);
end;

end.

Comments (6)

  1. Stefan Glienke repo owner

    Can reproduce on 10.1 but not on 10.2.

    I am sorry but I cannot help with compiler bugs, please report this to Embarcadero and/or update your Delphi version,

  2. Jens Mertelmeyer reporter

    This is probably outside of the scope of this ticket, but how is this supposed to be covered by the Build process/tests? When running build.exe (and only ticking the box for iOS 64), a console window shows up for several minutes, then disappears.

    To me, everything looked fine until I learned there is a logs subfolder. I have attached the build protocol. Is there some other kind of feedback I might be missing on the GUI of build.exe?

    Many thanks in advance.

  3. Stefan Glienke repo owner

    Check the "pause after each step" option and it leaves the console open and you can see if there was some error.

  4. Stefan Glienke repo owner

    Here is the minimal code to reproduce the issue:

    type
      TPair<TKey, TValue> = record
        Key: TKey;
        Value: TValue;
      end;
    
      ICollection<T> = interface
        function Extract(const item: T): T;
      end;
    
      IMap<TKey, TValue> = interface(ICollection<TPair<TKey, TValue>>)
      end;
    
      TMapBase<TKey, T> = class(TInterfacedObject, IMap<TKey, T>)
      public
        function Extract(const item: TPair<TKey, T>): TPair<TKey, T>; virtual; abstract;
      end;
    
    begin
      TMapBase<Integer,Integer>.Create;
    end.
    

    As I said this issue does not exist anymore in 10.2 so there is little sense to report it and there is not much to be done about this but removing the offending method for iOS64 in versions before 10.2. However there might be more places being affected by this and I don't want to spill any more ifdefs in the code than there are already (in fact we are considering to drop Delphi 2010 support for 1.3 to remove plenty of them).

  5. Log in to comment