Forum > Beginners
Generic function specialization compilation error
(1/1)
Laurent92:
Hello,
I got this compilation error while experimenting with generic classes and functions and I have no idea what could have caused it.
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Free Pascal Compiler version 3.2.2 [2021/05/16] for aarch64Copyright (c) 1993-2021 by Florian Klaempfl and othersTarget OS: Darwin for AArch64Compiling main.pasfgl.pp(1668,8) Note: Call to subroutine "function TFPGMap<System.ShortString,System.Pointer>.IndexOf(const AKey:ShortString):LongInt;" marked as inline is not inlinedmain.pas(44,1) Fatal: Internal error 2002071001Fatal: Compilation abortedError: /usr/local/bin/ppca64 returned an error exitcode
Is this a bug of the compiler (should I open an issue on GitLab?) or is it simply not possible to do that with Objet Pascal?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program main; uses TypInfo, FGL; type TIndex = 0..99; TGenericObjects = specialize TFPGMap<ShortString, Pointer>; generic TGenericObject<T> = class(TObject) private FList: array[TIndex] of T; public procedure Add(AIndex: TIndex; AElement: T); end; TGenericObjectFactory = class(TObject) public generic function GetGenericObject<T>: specialize TGenericObject<T>; generic procedure Add<T>(AIndex: TIndex; AElement: T); private FGenericObjects: TGenericObjects; end; generic function TGenericObjectFactory.GetGenericObject<T>: specialize TGenericObject<T>;var GenericObjectType: PTypeInfo;begin GenericObjectType := TypeInfo(T); Result := specialize TGenericObject<T>(FGenericObjects[GenericObjectType^.Name]^);end; generic procedure TGenericObjectFactory.Add<T>(AIndex: TIndex; AElement: T);var GenericObject: specialize TGenericObject<T>;begin GenericObject := specialize GetGenericObject<T>; // <-- this line causes the bug GenericObject.Add(AIndex, AElement);end; procedure TGenericObject.Add(AIndex: TIndex; AElement: T);begin FList[Aindex] := AElement;end; beginend.
Bart:
No internal error using fpc main, so probably fixed.
Now someone should test fpc 3.2 fixes branch.
Bart
TRon:
--- Quote from: Bart on November 27, 2024, 03:21:28 pm ---Now someone should test fpc 3.2 fixes branch.
--- End quote ---
No issues with fixes 3.2 but tested on x86_64 only.
Navigation
[0] Message Index