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
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to