EAccessViolation in IncRefCount (line 636 of symtype.pas) with generics and managed types
Summary
Access violation in compiler in IncRefCount (line 636 of symtype.pas) occurs when combining managed types, generics, and nested types referencing the parent type.
Steps to reproduce
This is the smallest repro I could come up with. Removing almost any component of this prevents the crash.
{$MODE OBJFPC}
{$MODESWITCH ADVANCEDRECORDS+}
program test;
type
generic TManagedType <T> = record
class operator Initialize(var Value: TManagedType);
function Test(): T;
end;
class operator TManagedType.Initialize(var Value: TManagedType);
begin
end;
function TManagedType.Test(): T;
begin
Result := Default(T);
end;
type
TRecord = record
type
TUnusedTypeDef = specialize TManagedType<TRecord>;
var
FManagedField: array of Integer; // any managed type
end;
begin
end.
System Information
- Operating system: Linux
- Processor architecture: x86-64
- Compiler version: trunk compiled on 2026/01/30
- Device: Computer