[fpc-devel] Black List of examples that FPC won't compile.

Maciej Izak hnb.code at gmail.com
Tue Jan 28 10:01:07 CET 2014

> I suggest a modification to your example:
> Please observe this: http://pastebin.com/9axN51QE
> If you declare a base class with "reintroduced" constructor (like I
> suggest) then you may prevent FreePascal compiler from "seeing"
> TObject.Create constructor. Therefore it will determine which constructor
> to call; so you won't get a compiler error in this example. I think that
> the fact that it can not determine which constructor to call when
> TObject.Create overloaded constructor is in scope is just logical; it
> should work this way. However if Delphi compiler uses a different kind of
> logic here then perhaps we can call it a bug; but only for Delphi mode;
> while ObjFPC mode should be left unchanged considering this particular
> problem.

The main problem is:

1. The error is not only about constructors

2. Reintroduce does not solve the problem

3. TObject.Create, shouldn't be visible in any way from TB (where is
visible - and this is a bug. Is visible, but you can call it in any way)
and TA level. Sadly when we calling the constructor for TB, TObject.Create
is still visible (only when there exist default value for parameter in TA)
- but sould be hidden for ever at TA leve, for any TA child. Following by
current logic, this example should not compile:

------begin code------
TA = class
  procedure Foo;

TB = class(TA)
  procedure Foo(A: Integer = 0); overload;

  b: TB;
  b := TB.Create;
  b.Foo; // should raise Error: Can't determine which overloaded function
to call
------end code------

I want use ObjFPC too :) I see any single reson to don't fixing this... No
side effects.

Returning to the example from bugtracker (
FPC don't recognize at TB level that the TObject.Create was hidden on the
TA level by

constructor Create(A: Integer = 0); virtual; overload;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140128/65fdf9be/attachment.html>

More information about the fpc-devel mailing list