Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-06

Bug: using @ with procedures in FPC

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sergey Korshunoff
Hello!
Look at program:
==============================================================
{$T+}
program hello2;
 type TP = procedure;
 type PP = ^TP;
var
  p1: TP;
  p2: PP;
procedure A;
  begin
   writeln('Hello world');
  end;
begin
  p1:=a;
  ;
  p2^();
end.
==============================================================

This program is work OK when compiled by FPC in -S2 mode (OBJFPC). But it is crashing if compiled by FPC in -Sd mode (Delphi). We have the same behavior when we compile with Kylix (DCC). I think there is a problem: compilers do not tell us any warning but generate a wrong code.

If to replace

    ;

with

    p2:=@@p1;

then DCC compiled binary work OK. But FPC do not compile this.

Regards,
Sergey Korshunoff

Reply by email

Peter Vreman
Show quoted text 26 lines
Hello! Look at program: ============================================================== {$T+} program hello2; type TP = procedure; type PP = ^TP; var p1: TP; p2: PP; procedure A; begin writeln('Hello world'); end; begin p1:=a; ; p2^(); end. ============================================================== This program is work OK when compiled by FPC in -S2 mode (OBJFPC). But it is crashing if compiled by FPC in -Sd mode (Delphi). We have the same behavior when we compile with Kylix (DCC).

That is because the procedure variables are not cleanly implemented in Tp/Delphi, sometimes you need the @ and even sometimes @@.

Show quoted text 8 lines
I think there is a problem: compilers do not tell us any warning but generate a wrong code. If to replace ; with p2:=@@p1; then DCC compiled binary work OK. But FPC do not compile this.

That's then a bug in the delphi mode code. For FPC mode it is not allowed.

Reply by email