Skip to content

Helpers inside generics

Summary

Compilation raised exception internally

System Information

  • Operating system: Windows
  • Processor architecture: x86-64
  • Compiler version: trunk
  • Device: Computer

Steps to reproduce

program Project1;
{$mode objfpc}{$H+}
uses
  gmap,gutil;
type
  generic GMyMap<TKey, TValue, TCompare>=class(specialize TMap<TKey, TValue, TCompare>)
    type
      TSelf=specialize GMyMap<TKey, TValue, TCompare>;
      TMyMapHelper = class helper for TSelf
        function test:integer;
      end;
  end;
function GMyMap.TMyMapHelper.test:integer;
begin
  result:=FSet.Size;
end;
begin
end.

output:

Hint: (11030) Start of reading config file Y:\pp\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file Y:\pp\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.3.1 [2024/03/28] for x86_64
Copyright (c) 1993-2024 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling D:\TEMP\project1.lpr
D:\TEMP\project1.lpr(13,35) Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $000000010008AC4C:
EStackOverflow: Stack overflow or stack misalignment
  $000000010008AC4C  ADD_HELPERS_AND_GENERICS,  line 1815 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas
  $000000010008AE8F  ADD_HELPERS_AND_GENERICS,  line 1847 of symdef.pas

Error: Y:\pp\bin\x86_64-win64\ppcx64.exe returned an error exitcode 

I understand that this is a terrible example, but it should either work or give a syntax error message.

Edited by Andrey Zubarev
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information