Hi,
The program below can be compiled with fpc 1.0.10, but not with this week's fpc 1.1.
With fpc 1.0.10 it gives the following output, (which is as I would expect).
TSubClass.Create
TBase.Create
fpc 1.1 gives the following error message:
overloadedcontructor.pas(36,32) Error: Can't determine which overloaded function to call overloadedcontructor.pas(19,19) Hint: Found declaration: constructor TBase.Create(TComponent)
overloadedcontructor.pas(26,23) Hint: Found declaration: constructor TSubClass.Create(TStrings) overloadedcontructor.pas(39) Fatal: There were 1 errors compiling module, stopping
How would you classify this incompatibility? A bug in fpc 1.0.10, a bug in fpc 1.1 or something else?
This situation surfaced as I tried to compile lazarus with fpc 1.1. I found out that I compile this source if I changed the call to the constructor to
test := TSubClass.Create(TStrings(nil));
Regards,
Vincent Snijders.
program overloadedcontructor;
{$mode objfpc}{$H+}
uses
Classes;
type
TBase = class
Constructor Create(Owner: TComponent);
end;
TSubClass = class(TBase)
Constructor Create(strings : TStrings);
end;{ TBase }
constructor TBase.Create(Owner: TComponent);
begin
writeln('TBase.Create');
end;{ TSubClass }
constructor TSubClass.Create(strings: TStrings);
begin
writeln('TSubClass.Create');
inherited Create(nil);
end;
var
test: TBase;
begin
test := TSubClass.Create(nil);
end.