Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Generics    [ Add a report in this area ]  
Report #:  109187   Status: Closed
[REGRESSION from XE2] Generic Class with Generic Dynamic Array, URW1147
Project:  Delphi Build #:  17.0.4625.53395
Version:    17.0 Submitted By:   Steffen Binas
Report Type:  Crash / Data loss / Total failure Date Reported:  10/1/2012 11:36:15 AM
Severity:    Serious / Highly visible problem Last Updated: 4/23/2013 8:06:37 AM
Platform:    All platforms Internal Tracking #:   32373
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE4
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 40
Description
Compiler throws internal Error URW1147 when compiling the a generic class with a generic dynamic array assigned in a local method.

This code used to compile in XE2.
Steps to Reproduce:
- dcc -B GenericErrorPrj.dpr

//// File: GenericDefinition.pas

unit GenericDefinition;

interface

type
   TRec<T> = record
     Value : T;
   end;
   TRecArray<T> = array of TRec<T>;

   TFoo<T> = class
      private
         FRecs : TRecArray<T>;
      protected
         procedure Bar;
      public
   end;

implementation

procedure TFoo<T>.Bar;
var
  A: TRecArray<T>;
begin
  A := FRecs; // <------ Comment this out to make the error go away
end;

end.

//// <------- Crashes here with URW1147

//// File: GenericConsumer.pas

unit GenericConsumer;

interface

uses
  GenericDefinition;

type
  TMyClass = class(TFoo<TObject>)
  end;

procedure TestXE3Bug;

implementation

procedure TestXE3Bug;
var
  Hash: TMyClass;
begin
  Hash := TMyClass.Create;
end;

end.

//// File: GenericErrorPrj.dpr
program GenericErrorPrj;

uses
  GenericDefinition,
  GenericConsumer;

begin
  TestXE3Bug;
end.
Workarounds
procedure TFoo<T>.Bar_Workaround;
var
  A: TRecArray<T>;
begin
  A := nil; // <--- Add this line to make the error go away
  A := FRecs;
end;
Attachment
None
Comments

None

Server Response from: ETNACODE01