Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Generics    [ Add a report in this area ]  
Report #:  103798   Status: Open
Class constructors for generic classes do not run if all code is in a .dpr file
Project:  Delphi Build #:  15.0.3953.35171
Version:    15.1 Submitted By:   David Heffernan
Report Type:  Crash / Data loss / Total failure Date Reported:  2/29/2012 7:22:13 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   271693
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (2 Total Ratings)
5.00 out of 5
Total Votes: 42
Description
Class constructors for generic classes do not run if all code is in a .dpr file.

Moving code to a separate .pas unit is sufficient to workaround the problem.
Steps to Reproduce:
The class constructor in the following program is not executed.

program ClassConstructorBug;

{$APPTYPE CONSOLE}

type
  TTestClass<T> = class
  private
    class constructor Create;
  end;

class constructor TTestClass<T>.Create;
begin
  Writeln('class created');
end;

begin
  TTestClass<Integer>.Create;
end.
Workarounds
None
Attachment
None
Comments

Tomohiro Takahashi at 4/17/2012 6:45:20 AM -
This report was opened with valid Internal Tracking Number.
Thanks.

Server Response from: ETNACODE01