[fpc-devel] specialization with type alias, bug or feature

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Aug 17 12:17:15 CEST 2023


Hi,

FPC and Delphi handle type alias differently and I wonder if this was 
deliberate.

type
   TMyDouble = type double;

   TBird<T> = class
     a: T;
   end;
   TDoubleBird = TBird<double>;
   TMyDoubleBird = TBird<TMyDouble>;

Both FPC and Delphi create different classes for TDoubleBird and 
TMyDoubleBird.

In Delphi they are not assign compatible, in FPC they are. For example:
var
   a: TDoubleBird;
   b: TMyDoubleBird;
begin
   b:=TMyDoubleBird.Create;
   a:=b; // forbidden in Delphi
   writeln(a is TDoubleBird); // writes false

Bytewise the assignment is ok, but logic wise "a" is no longer a 
TDoubleBird.

Is this a bug or a feature?

Mattias


More information about the fpc-devel mailing list