View Issue Details

IDProjectCategoryView StatusLast Update
0038828FPCCompilerpublic2021-04-30 10:02
Reportermartijnn Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platformi386/x86_64OSwin32/win64/darwin 
Product Version3.2.0 
Summary0038828: Incorrect compiler error "Incompatible types" when using Default on array of pointers and elements (in some cases)
DescriptionWhen compiling a pascal program involving an array of typed pointers initialized with Default() and subsequently a dynamically allocated element initialized with Default() too, fpc >= 3.2 returns a compiler error: "Incompatible types" mentioning the wrong type.

Strange enough this only happens when the method prototype the code is contained in hits vague limits, i.e. the class name, name or parameter list exceeds a certain length.

Encountered in:
- i386/win32 (3.2.0+3.2.2rc1)
- x86_64/win64 (3.2.0+3.2.2rc1)
- Darwin (3.2.0)
Steps To Reproduce- Compile the attached program that produces the error
- Follow any of the resolutions in the code to resolve the error
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

martijnn

2021-04-30 10:00

reporter  

ptrdef.pp (855 bytes)   
program ptrdef;

type
  TTestClassWithLongName = class
  public
    procedure MyMethodWithLongName(p1, p2, p3, p4, p5, p6, p7, p8: Integer);
  end;

{
  fpc 3.0.4 -> ok
  fpc 3.2.0 + fpc 3.2.2rc1 -> Error: Incompatible types: got "MyrecPtrArray" expected "TMyrec" at (2)

  Error goes away when one of the following changes is made:

  - Class name shortened
  - Method name shortened
  - Parameter list reduced
  - Statement (1) commented
  - Statement (2) commented
}

procedure TTestClassWithLongName.MyMethodWithLongName(p1, p2, p3, p4, p5, p6, p7, p8: Integer);
type
  TMyrec = record
  end;
  PMyrec = ^TMyrec;

  MyrecPtrArray = array[0..1] of PMyrec;
var
  ma: MyrecPtrArray;
begin
  ma := Default(MyrecPtrArray); // (1)
  New(ma[0]);
  ma[0]^ := Default(TMyrec); // (2)
  Dispose(ma[0]);
end;

begin

end.
ptrdef.pp (855 bytes)   

Issue History

Date Modified Username Field Change
2021-04-30 10:00 martijnn New Issue
2021-04-30 10:00 martijnn File Added: ptrdef.pp