Compare procedural pointers in XE6

The following sample program, compiled with Delphi XE2 and earlier:

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

{$TYPEDADDRESS ON}

type
  TMyProc = procedure(Dummy: Integer);

procedure MyProcA(Dummy: Integer);
begin
  //
end;

var
  MyProcVar: TMyProc;

function Test: Boolean;
begin
  Result := @MyProcVar = @MyProcA;
end;

begin
  if Test then
    Writeln('OK');
end.

      

It no longer compiles in XE6 with an error

[dcc32 Fehler] Project1.dpr (22): E2008 Inkompatible Typen

which translates to

[dcc32 error] Project1.dpr (22): E2008 Incompatible types

If I switch to {$TYPEDADDRESS OFF}

or Addr(MyProcVar) = Addr(MyProcA)

, it compiles. Is this a bug in XE6 or in XE2 that maybe shouldn't have compiled it?

+3
delphi function-pointers delphi-xe6


source to share


No one has answered this question yet

See similar questions:

6
Why are the format rejection method address arguments since XE4

or similar:

1119
How do function pointers work in C?
nineteen
How does Delphi resolve overloaded functions with integral parameters?
eleven
How does WriteLn () work?
eleven
Can I change the constant in the RTL System.Classes.TStream class and rebuild it at runtime in Delphi XE6?
2
Delphi string / array of strings
1
weird problem with dxComponentPrinter1
1
Delphi xe2 installation problem
1
which safearraygetdata function takes saferray as an input parameter in Delphi instead of vararray
0
How to pass row indices to OleVariant
-1
NPAPI Module Plugin Error



All Articles
Loading...
X
Show
Funny
Dev
Pics