[fpc-pascal] Generics problem/question

Honza befelemepeseveze at gmail.com
Thu Jan 14 17:37:35 CET 2010


Hi all.

At Mantis Florian already explained, why it is not possible to provide
more information in the error message. Still he meanwhile managed to
make it better. I got some time to return to this and now I'm here:

17:11 myname at tux64:~/fpc/bugreports/20100105$ cat project1.pas
program project1;

{$mode objfpc}{$H+}

uses
	fgl;

type
  TPar = record
    I: Integer;
  end;

operator = (A, B: TPar): Boolean;
begin
	Result := A.I = B.I;
end;

type
  TSpec = specialize TFPGList<TPar>;

begin
end.

17:22 myname at tux64:~/fpc/bugreports/20100105$ fpc project1.pas
Free Pascal Compiler version 2.5.1 [2010/01/14] for x86_64
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for x86-64
Compiling project1.pas
Error: Operator is not overloaded: "<record type>" = "<record type>"
project1.pas(24) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /home/myname/lib/fpc/2.5.1/ppcx64 returned an error exitcode
(normal if you did not specify a source file to be compiled)
17:22 myname at tux64:~/fpc/bugreports/20100105$ svn info ~/svn/fpc/trunk
Path: /home/myname/svn/fpc/trunk
URL: http://svn2.freepascal.org/svn/fpc/trunk
Repository Root: http://svn2.freepascal.org/svn/fpc
Repository UUID: 3ad0048d-3df7-0310-abae-a5850022a9f2
Revision: 14633
Node Kind: directory
Schedule: normal
Last Changed Author: paul
Last Changed Rev: 14633
Last Changed Date: 2010-01-14 09:41:27 +0100 (Čt, 14 led 2010)

17:23 myname at tux64:~/fpc/bugreports/20100105$

I'm now able to track the source of the error message to line 715:50
of rtl/objpas/fgl.pp:

711  function TFPGList.IndexOf(const Item: T): Integer;
712  begin
713    Result := 0;
714    {$info TODO: fix inlining to work! InternalItems[Result]^}
715    while (Result < FCount) and (PT(FList)[Result] <> Item) do
716      Inc(Result);
717    if Result = FCount then
718      Result := -1;
719  end;

Still I'm stuck and don't know how to use items like TPar in the
specialization of TFPGList - or if it is a compiler bug.

Thanks in advance for anyone's help/explanation/hint.

-bflm

Topic/previous messages context:
http://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg18933.html

Mantis issue:
http://bugs.freepascal.org/view.php?id=15480



More information about the fpc-pascal mailing list