Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/Other RTL    [ Add a report in this area ]  
Report #:  115377   Status: Closed
AV when creating a generic Delphi TList<TClass> in BCB
Project:  C++Builder Build #:  18.0.4854.59655
Version:    18.0 Submitted By:   David Berneda
Report Type:  Crash / Data loss / Total failure Date Reported:  4/30/2013 5:49:55 AM
Severity:    Critical / Show Stopper Last Updated: 4/15/2014 6:18:11 PM
Platform:    All platforms Internal Tracking #:   39017
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: None
Description
Creating a Delphi TList<TClass> object instance from BCB raises AV.

It happens in win32 and win64, and with/without Dynamic RTL.
Steps to Reproduce:
-Open attached project group

-Run Project114 (Delphi), no errors.
-Run Project115 (BCB)

Exp: No errors
Act: AV

Both projects use the same Unit_Foo.pas Delphi unit.

The problem is declaring the generic TList with TClass (classtype) type:

[Unit9.cpp]
----------
#include "Unit_Foo.hpp"
...
...
//---------------------------------------------------------------------------
__fastcall TForm9::TForm9(TComponent* Owner) : TForm(Owner)
{
  Test();
}
----------

[Unit_Foo.pas]
----------
unit Unit_Foo;

interface

uses
  System.Generics.Collections;

type
  TBar=class
  end;

  TBarClass=class of TBar;

  TBarList=TList<TBarClass>;  // <-- TList<TBar> works fine with BCB

var
  Foo:TBarList;

procedure Test;

implementation

procedure Test;
begin
  Foo:=TBarList.Create; // <<------ Access Violation
end;

initialization
//  Test;
end.
----------
Workarounds
None
Attachment
QC115377.zip
Comments

Tomohiro Takahashi at 4/30/2013 6:35:42 AM -
> -Run Project115 (BCB)
Coud you try to turn off 'Link with Runtime packages' option?

and, is this a regression in C++Builder XE4? What about previous versions of C++Builder?

David Berneda at 5/1/2013 3:15:12 AM -
Yes, it works when turning off runtime packages.  
There is a difference in the autogenerated Unit_Foo.hpp header with and without runtime packages.
With packages, it has a #pragma pack push/pop.

XE3: AV happens with and without runtime packages.

Server Response from: ETNACODE01