[fpc-pascal] "Double" specialization of generic class

Xiangrong Fang xrfang at gmail.com
Tue Apr 15 11:51:16 CEST 2014


2014-04-15 17:21 GMT+08:00 Sven Barth <pascaldragon at googlemail.com>:

> Am 15.04.2014 08:47 schrieb "Xiangrong Fang" <xrfang at gmail.com>:
>  > It's good to know that it works, at least in 2.7.1.   I will report the
> problem again while I start using 2.7.1 or when it is released as 2.8 :-)
>
> That's the point: I don't know wether it compiles in 2.7.1 as I did not
> test it. If you could provide a minimal sample (which fails in 2.6.2) and
> report that as a bug I could ensure that 2.7.1 works correctly there.
>

​I cannot replicate the problem using a minimal program, because it gives
out different error message.  The following minimal program compiles OK:

program vectr;
type
  generic TGeneric1<T> = class

  end;
  generic TGeneric2<T> = class

  end;
  TSpec1 = specialize TGeneric1<Integer>;
  TSpec2 = specialize TGeneric2<TSpec1>;
begin
end.

While the following program generate different error:

program vectr;
uses
  treap, vector;
type
  TNodeHash = specialize TTreap<Integer, string>;
  TNodeVector = class(specialize TVector<TNodeHash>)
  protected
    function OnSort(v1, v2: T): Integer; override;
  end;

operator <(nh1, nh2: TNodeHash): Boolean;
begin
  Result := nh1.Count < nh2.Count;
end;
operator >(nh1, nh2: TNodeHash): Boolean;
begin
  Result := nh1.Count > nh2.Count;
end;

function TNodeVector.OnSort(v1, v2: T): Integer;
begin
  Result := 0;
end;

begin
end.    ​

gives error message:

vector.pas(149,9) Error: Operator is not overloaded:
"TTreap$LongInt$AnsiString" < "TTreap$LongInt$AnsiString"
vector.pas(151,14) Error: Operator is not overloaded:
"TTreap$LongInt$AnsiString" > "TTreap$LongInt$AnsiString"
vectr.lpr(28) Fatal: There were 2 errors compiling module, stopping

The two used units can be downloaded here:

https://github.com/xrfang/fpcollection/

While in my real program, I have this:

type
  TCmhWaves = specialize TVector<TCmhWave>;

The thing is, even if I do NOT use this definition at all, it still crashes
the compiler.  By "crash" I mean I get this from lazarus:

Compiling wmodel.lError: /usr/bin/ppcx64 can't be executed, error message:
Failed to execute "/usr/bin/ppcx64", error code: -139

TCmhWave is a specialized subclass of My TTreap class (also on github), it
does NOT overload the < and > operators either.

So my question is:

1) why my simplified example still require overloaded operator, although I
have already done so?

2) If this is the cause of error (TCmhWave does not have these operators
defined), why the compiler returns error code: -139 instead of more
detailed errors?

BTW, on my first attempt to debug this problem in lazbuild (command line) I
get some error related to VMA, but unfortunately I forgot what it is and
cannot get it shown again. Is there any way to customize the lazbuild by
some switches to let it output more messages?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140415/899019a9/attachment.html>
-------------- next part --------------
xrfang at OP380:~/Sync/wmodel$ lazbuild wmodel.lpi
primary config path: /home/xrfang/.lazarus
TPkgManager.CheckCompileNeedDueToDependencies  State file of LCL 1.2.0.3 is newer than state file of Package: cairocanvas_pkg 0.0
TLazPackageGraph.CheckIfPackageNeedsCompilation normal output dir is not writable: /usr/share/lazarus/1.2.0/components/cairocanvas/lib/x86_64-linux/gtk2/
TLazPackageGraph.GetFallbackOutputDir  cairocanvas_pkg: /home/xrfang/.lazarus/lib/cairocanvas_pkg/lib/x86_64-linux/gtk2
TParsedCompilerOptions.SetOutputDirectoryOverride New=/home/xrfang/.lazarus/lib/cairocanvas_pkg/lib/x86_64-linux/gtk2
TLazPackageGraph.CheckIfCurPkgOutDirNeedsCompile  Compiler params changed for Printer4Lazarus 0.5
  Old=" -MObjFPC -Scgi -O1 -g -gl -vewnhi -Fi/usr/share/lazarus/1.2.0/components/printers/unix -Fi/usr/share/lazarus/1.2.0/components/printers/win32 -Fi/usr/share/lazarus/1.2.0/components/printers/carbon -Fi/usr/share/lazarus/1.2.0/components/printers/qt -Fu/usr/share/lazarus/1.2.0/components/printers/unix -Fu/usr/share/lazarus/1.2.0/components/printers/win32 -Fu/usr/share/lazarus/1.2.0/components/printers/carbon -Fu/usr/share/lazarus/1.2.0/components/printers/qt -Fu/usr/share/lazarus/1.2.0/packager/units/x86_64-linux -Fu/usr/share/lazarus/1.2.0/components/lazutils/lib/x86_64-linux -Fu/usr/share/lazarus/1.2.0/lcl/units/x86_64-linux -Fu/usr/share/lazarus/1.2.0/lcl/units/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.2.0/components/cairocanvas/lib/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.2.0/components/printers/ -FU/usr/share/lazarus/1.2.0/components/printers/lib/x86_64-linux/gtk2/ -l -dLCL -dLCLgtk2 -dUseCache -dNativePrint -dUSEUNICODE printer4lazarus.pas"
  Now=" -MObjFPC -Scgi -O1 -g -gl -vewnhi -Fi/usr/share/lazarus/1.2.0/components/printers/unix -Fi/usr/share/lazarus/1.2.0/components/printers/win32 -Fi/usr/share/lazarus/1.2.0/components/printers/carbon -Fi/usr/share/lazarus/1.2.0/components/printers/qt -Fu/usr/share/lazarus/1.2.0/components/printers/unix -Fu/usr/share/lazarus/1.2.0/components/printers/win32 -Fu/usr/share/lazarus/1.2.0/components/printers/carbon -Fu/usr/share/lazarus/1.2.0/components/printers/qt -Fu/usr/share/lazarus/1.2.0/packager/units/x86_64-linux -Fu/usr/share/lazarus/1.2.0/components/lazutils/lib/x86_64-linux -Fu/usr/share/lazarus/1.2.0/lcl/units/x86_64-linux -Fu/usr/share/lazarus/1.2.0/lcl/units/x86_64-linux/gtk2 -Fu/home/xrfang/.lazarus/lib/cairocanvas_pkg/lib/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.2.0/components/printers/ -FU/usr/share/lazarus/1.2.0/components/printers/lib/x86_64-linux/gtk2/ -l -dLCL -dLCLgtk2 -dUseCache -dNativePrint -dUSEUNICODE printer4lazarus.pas"
  State file="/usr/share/lazarus/1.2.0/components/printers/lib/x86_64-linux/gtk2/Printer4Lazarus.compiled"
TLazPackageGraph.CheckIfPackageNeedsCompilation normal output dir is not writable: /usr/share/lazarus/1.2.0/components/printers/lib/x86_64-linux/gtk2/
TLazPackageGraph.GetFallbackOutputDir  Printer4Lazarus: /home/xrfang/.lazarus/lib/Printer4Lazarus/lib/x86_64-linux/gtk2
TParsedCompilerOptions.SetOutputDirectoryOverride New=/home/xrfang/.lazarus/lib/Printer4Lazarus/lib/x86_64-linux/gtk2
TBuildManager.CheckIfProjectNeedsCompilation  Compile was incomplete for Project
[TExternalToolList.Run] CmdLine="/home/xrfang/Sync/wmodel/gitrev.exe" WorkDir="/home/xrfang/Sync/wmodel/"
"Executing command before" completed
TCompiler.Compile WorkingDir="/home/xrfang/Sync/wmodel/" CompilerFilename="/usr/bin/fpc" CompilerParams=" -MObjFPC -Scghi -O1 -g -gl -vewnhi -Fi/home/xrfang/wmodel/lib/x86_64-linux -Fl/opt/gnome/lib -Fu/home/xrfang/git/fpcollection/src/units -Fu/home/xrfang/.lazarus/lib/Printer4Lazarus/lib/x86_64-linux/gtk2 -Fu/home/xrfang/.lazarus/lib/cairocanvas_pkg/lib/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.2.0/lcl/units/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.2.0/lcl/units/x86_64-linux -Fu/usr/share/lazarus/1.2.0/components/lazutils/lib/x86_64-linux -Fu/usr/share/lazarus/1.2.0/packager/units/x86_64-linux -Fu/home/xrfang/Sync/wmodel/ -FU/home/xrfang/wmodel/lib/x86_64-linux/ -l -FE/home/xrfang/wmodel/ -dLCL -dLCLgtk2 wmodel.lpr"
[TCompiler.Compile] CmdLine="/usr/bin/fpc  -MObjFPC -Scghi -O1 -g -gl -vewnhi -Fi/home/xrfang/wmodel/lib/x86_64-linux -Fl/opt/gnome/lib -Fu/home/xrfang/git/fpcollection/src/units -Fu/home/xrfang/.lazarus/lib/Printer4Lazarus/lib/x86_64-linux/gtk2 -Fu/home/xrfang/.lazarus/lib/cairocanvas_pkg/lib/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.2.0/lcl/units/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.2.0/lcl/units/x86_64-linux -Fu/usr/share/lazarus/1.2.0/components/lazutils/lib/x86_64-linux -Fu/usr/share/lazarus/1.2.0/packager/units/x86_64-linux -Fu/home/xrfang/Sync/wmodel/ -FU/home/xrfang/wmodel/lib/x86_64-linux/ -l -FE/home/xrfang/wmodel/ -dLCL -dLCLgtk2 wmodel.lpr"
Hint: Start of reading config file /etc/fpc.cfg
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 2.6.2-5 [2013/07/25] for x86_64
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling wmodel.lError: /usr/bin/ppcx64 can't be executed, error message: Failed to execute "/usr/bin/ppcx64", error code: -139
ERROR: failed compiling of project /home/xrfang/Sync/wmodel/wmodel.lpi
xrfang at OP380:~/Sync/wmodel$ 



More information about the fpc-pascal mailing list