Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Generics    [ Add a report in this area ]  
Report #:  122107   Status: Closed
sizeof generic type is wrong / inconsistent
Project:  Delphi Build #:  19.0.14356.6604
Version:    19.2 Submitted By:   Gabriel Corneanu
Report Type:  Basic functionality failure Date Reported:  1/30/2014 12:47:38 AM
Severity:    Infrequently encountered problem Last Updated: 4/15/2014 6:32:37 PM
Platform:    All platforms Internal Tracking #:   47088
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE6
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 10
Description
I had a previous similar report (QC#90688) which is closed now.

Inside the steps is the reproducible code, just copy/paste in an empty project.

It looks like the compiler fails with some nested generic types.
Steps to Reproduce:
Create empty project and paste this code:

[Output]
8
0

[Test Case]
------------
program Project32;
{$APPTYPE CONSOLE}

type
  TGenRec1<T: record> = record
    const
      cSize = sizeof(T);

    class function getsize: integer; static;
  end;

  TGenRec2<T: record> = record
  type
    TRecWrap = TGenRec1<T>;
    class function getsize: integer; static;
  end;

class function TGenRec1<T>.getsize: integer;
begin
  Result := cSize;
end;

class function TGenRec2<T>.getsize: integer;
begin
  Result := TRecWrap.cSize;
end;

type
  TMyRec1 = TGenRec1<double>;
  TMyRec2 = TGenRec2<double>;
begin
  writeln(TMyRec1.getsize);
  writeln(TMyRec2.getsize);
  readln;
end.
------------
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01