FPC compiler bug: functional parameter invocation

Régis Cridlig cridlig at gmail.com
Thu Apr 3 19:59:45 CEST 2008


Hello!

This short program compiles without a warning, but crashes at execution. The
compiler is FPC 2.2 on the win32 platform.

program Crashes(input,output);

function B(l:integer):boolean;
begin
        B:=true;
end;

procedure Q(j:integer;function A(l:integer):boolean);

        function E(l:integer):boolean;
        begin
                E := false
        end;

  begin
        if A(j) then
            Q(200,E);
  end;

begin
        Q(100,B);
end.

This is the compiler command:
$ gpc --classic-pascal -g -Wall crashes.p

Here are the stack frames from gdb:

Loaded symbols for /cygdrive/c/WINDOWS/system32/ntdll.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/kernel32.dll
Loaded symbols for /usr/bin/cygwin1.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/advapi32.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/rpcrt4.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/secur32.dll

Program received signal SIGSEGV, Segmentation fault.
0x0022cc20 in ?? ()
(gdb) bt
#0  0x0022cc20 in ?? ()
#1  0x004010a9 in _p__M0_S1_Q (J=200, A=@0x22cc20) at crashes.p:16
#2  0x004010c6 in _p__M0_S1_Q (J=100, A=@0x401050) at crashes.p:16
#3  0x004010e2 in _p__M0_main_program () at crashes.p:20
#4  0x0040115b in main (argc=1, argv=0x6927b0, envp=0x690090)
    at <implicit code>:22

I am pretty sure that this is a compiler bug, because this program used to
run on MacPascal with no error.

-- Regis Cridlig
cridlig at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.g-n-u.de/pipermail/gpc/attachments/20080403/2a499312/attachment.htm>


More information about the Gpc mailing list