View Issue Details

IDProjectCategoryView StatusLast Update
0037108FPCCompilerpublic2020-05-18 19:19
ReporterGeorge Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformLinux x64OSUbuntu 
Product Version3.0.4 
Summary0037108: Compiler reports error on usage of SizeOf of a type parameter in constant value
DescriptionSee example.
Compiler reports "Error: (3203) Illegal expression" at line 12.
And "Error: (5000) Identifier not found "Size"" at line 14.
Both are wrong.
The errors do not appear if T is constrained by "record" or the constant value set to only "SizeOf(T)". I.e. without operations.
FPC v3.2.0 RC1 behaviour is the same.
Steps To Reproduceprogram genTest;

{$IFDEF FPC}{$mode Delphi}{$ENDIF}

type
  TTest<T> = class(TObject)
    procedure testit();
  end;

procedure TTest<T>.testit();
const
  Size = SizeOf(T) * 2;
begin
  WriteLn('=== ', Size)
end;
  
begin
  TTest<Char>.Create().TestIt();
end.
Tagsgenerics
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2020-05-18 19:18 George New Issue
2020-05-18 19:19 George Tag Attached: generics