Declaring specializations within procedures/functions causes Compilation aborted error
Original Reporter info from Mantis: ahydra
-
Reporter name: Colin Haywood
Original Reporter info from Mantis: ahydra
- Reporter name: Colin Haywood
Description:
See program below. When you try to compile it, FPC gives the "Compilation aborted" error at line 1. I've also seen unhandled exceptions or access violations when compiling more complex programs.
When the TMyIntegerArray definition is moved to the global type section, the program compiles fine.
Steps to reproduce:
program Project1;
{$mode objfpc}{$H+}
uses
Classes;
type
generic TgenTest<_T> = class
type public
T_TArray = array of _T;
var private
FArray: T_TArray;
public
constructor Create();
procedure Init(Value: _T);
end;
constructor TgenTest.Create();
begin
SetLength(FArray, 5);
end;
procedure TgenTest.Init(Value: _T);
var
i: integer;
begin
for i := 0 to High(FArray) do FArray[i] := Value;
end;
procedure BreakMyProgram();
type
TMyIntegerArray = specialize TgenTest<integer>;
var
IA: TMyIntegerArray;
begin
IA := TMyIntegerArray.Create();
IA.Init(42);
end;
begin
BreakMyProgram();
end.
Mantis conversion info:
- Mantis ID: 20068
- OS: Windows
- OS Build: XP Home
- Platform: x86
- Version: 2.4.2
- Fixed in version: 2.6.0